问题描述
Hello Folks,
遇到了一个问题,我从一天开始一直在努力.
我有一个包含varchar列和XML列的表.架构如下:
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>')
我需要使用实体填充列表框,如下所示:
名字
SecondName
ThirdName
填充编写的列表框的代码如下:
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();
}
上面的代码将整个xml列以字符串格式放入列表框中,并且非常明显.
我尝试了一些xmlserializer,deserializer和xmlreader东西,但无法相应地填充列表框.
专家请指导.
任何帮助或指针都应该非常有帮助..
-问候
Anurag
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
推荐答案
这篇关于从具有XML列的表中填充ListBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!