2.0: DataView definition problem

Discussion in 'ASP .Net' started by R.A.M., Apr 12, 2006.

  1. R.A.M.

    R.A.M. Guest

    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/
    R.A.M., Apr 12, 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. R.A.M.

    2.0: DataView definition problem

    R.A.M., Apr 22, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    412
    R.A.M.
    Apr 22, 2006
  2. Jianli Shen
    Replies:
    1
    Views:
    582
    Victor Bazarov
    Mar 13, 2005
  3. Ark
    Replies:
    1
    Views:
    414
    Chris Torek
    Aug 7, 2004
  4. Jon Slaughter
    Replies:
    4
    Views:
    442
    Jon Slaughter
    Oct 26, 2005
  5. CodeMonkey
    Replies:
    1
    Views:
    725
    joyal jhaveri
    Feb 4, 2011
Loading...

Share This Page