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:
create table dbo.StandardView(
Name varchar(50),
Fields xml)
I inserted a record as below:
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:
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