Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > 2.0: DataView definition problem

Reply
Thread Tools

2.0: DataView definition problem

 
 
R.A.M.
Guest
Posts: n/a
 
      04-12-2006
Hello,
(sorry for my English...)
Please help me with a problem of DataView definition for DataTable
(DefaultView doesn't work). I have little experience.

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 ( had read) displayed.
dt.DefaultView doesn't work (same result).
Thank you for your answers.
/RAM/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sorted DataView, but unsorted datalist when bound to the dataview CodeMonkey ASP .Net 1 02-04-2011 10:55 AM
2.0: DataView definition problem R.A.M. ASP .Net 0 04-22-2006 03:19 PM
Automagic determination of definition based on definition location. Jon Slaughter C++ 4 10-26-2005 05:00 PM
can a class definition inside another class's definition Jianli Shen C++ 1 03-13-2005 06:02 PM
help?: incomplete definition with complete definition in scope Ark C Programming 1 08-07-2004 04:21 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57