Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello Folks,

Have landed in a problem, which I am tryin to work since a day.
I have a table having a varchar column and a XML column.The schema is below:
SQL
create table dbo.StandardView(
Name varchar(50),
Fields xml)

I inserted a record as below:
SQL
insert into dbo.StandardView values('Standard',N'<fieldname>FirstName,SecondName,ThirdName</fieldname>')


I need to populate a listbox with the entities as follows:
FirstName
SecondName
ThirdName
The code to populate the listbox written is as below:
C#
protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            PopulateValues();
        }

    }
    public void PopulateValues()
    {
        SqlDataAdapter da = new SqlDataAdapter("select * from dbo.StandardView", xconn);
        DataTable dt = new DataTable();
        da.Fill(dt);
        lstBox.DataSource = dt;
        lstBox.DataTextField = dt.Columns[1].ToString();
        lstBox.DataValueField = dt.Columns[1].ToString();
        lstBox.DataBind();

    }

The above code puts the whole xml column in the listbox in a string format and its pretty evident.
I tried some xmlserializer,deserializer and xmlreader stuffs but wasn't able to populate the listbox accordingly.
Experts please guide.
Any help or pointer should be pretty helpful..

-regards
Anurag
Posted
Comments
_Asif_ 5-Jul-13 5:49am    
How many rows will the query "select * from dbo.StandardView" returns? Lets say it return two rows in that case what would be the structure of your ListBox?
Anurag Sinha V 6-Jul-13 14:36pm    
thanks fr the reply mate..if my table has two rows then fourthname.fifthname,sixthname will come after the frst 3 entried vertically..i mean i will like it to be like dat...
u got ny idea???
will b very helpful

1 solution

 
Share this answer
 
Comments
Anurag Sinha V 7-Jul-13 0:44am    
Hey Mate...links look pretty ok...i will try and will update thread...
-regards
anurag

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900