.NET 2.0: DataView SIMPLE PROBLEM

Discussion in 'ASP .Net' started by R.A.M., May 15, 2006.

  1. R.A.M.

    R.A.M. Guest

    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/
     
    R.A.M., May 15, 2006
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jason
    Replies:
    1
    Views:
    1,499
    Hermit Dave
    Sep 22, 2004
  2. Manohar Kamath [MVP]

    Re: .Net Dataview vs. Using Database View

    Manohar Kamath [MVP], Sep 22, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    410
    Manohar Kamath [MVP]
    Sep 22, 2004
  3. Lucas Tam
    Replies:
    0
    Views:
    464
    Lucas Tam
    Sep 23, 2004
  4. =?Utf-8?B?TWlrZSBNb29yZQ==?=

    .Net Dataview vs. Using Database View

    =?Utf-8?B?TWlrZSBNb29yZQ==?=, Sep 22, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    352
    =?Utf-8?B?TWlrZSBNb29yZQ==?=
    Sep 22, 2004
  5. CodeMonkey
    Replies:
    1
    Views:
    771
    joyal jhaveri
    Feb 4, 2011
Loading...

Share This Page