.NET 2.0: DataView SIMPLE PROBLEM

R

R.A.M.

Hello,
Please help me with a problem of DataView definition for DataTable
(DefaultView doesn't work). I have little experience. I present the
problem here second time, because I haven't got any answers.

I have an asp:ListBox ID="DotNETWWW" which I would like to fill with
data from XML file. It works fine but my data is not displayed in
ListBox properly - instead, I got a list of "System.Data.DataRowView"
string items. I'd rather have URLs I had read.
Here's the code:

const string DotNETFile = ...;
using (DataTable dt = new DataTable())
try
{
dt.Columns.Add("url",
System.Type.GetType("System.String"));
using (XmlTextReader reader = new
XmlTextReader(Request.PhysicalApplicationPath + "App_Data\\" +
DotNETFile + ".xml"))
{
reader.MoveToContent();
while (!reader.EOF)
if (!(reader.NodeType == XmlNodeType.Element
&& reader.Name == "link"))
reader.Read();
else
{
DataRow dr = dt.NewRow();
dr["url"] = reader.Value.Trim();
dt.Rows.Add(dr);
}
}
}
catch (Exception ex)
{
dt.Rows.Clear();
}
finally
{
DataView dv = new DataView(dt); // HERE PROBLEM
DotNETWWW.DataSource = dv;
DotNETWWW.DataBind();
}

I don't know how to define view to have URLs (I had read) displayed.
Unfortunately dt.DefaultView doesn't work (same result).

Thank you very much for your answers.
/RAM/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top