.select filter on new datatable to produce datarows for .bind() -NEWBIE

Discussion in 'ASP .Net' started by jason@cyberpine.com, Nov 11, 2003.

  1. Guest

    Pardon the misguided NEWBIE question...

    I have an aspx application that will create a table, populate it and
    then I need to filter out select rows for binding into a datagrid.

    The following code works, minus the attempt to filter (.select) the
    dataset before binding. I know the select works as I can see it
    selecting rows with a response.write, but apparenlty I don't know how
    to bind selected datarows??

    The design calls for loading from an array and ending up with
    dataset/datatable. Yes - I could have skipped both the array and the
    datatable and used regex to filter the collected data and a for loop
    to load it into dropdown list - but not the point.

    The below code is failing with:
    System.Data.DataRow' does not contain a property with the name n4.


    =========code

    ' create table
    Dim dt As DataTable
    Dim dr As DataRow
    Dim i As Integer
    dt = New DataTable
    dt.Columns.Add(New DataColumn("n1", GetType(Integer)))
    dt.Columns.Add(New DataColumn("n2", GetType(Integer)))
    dt.Columns.Add(New DataColumn("n3", GetType(Integer)))
    dt.Columns.Add(New DataColumn("n4", GetType(Integer)))
    dt.Columns.Add(New DataColumn("n5", GetType(Integer)))
    dt.Columns.Add(New DataColumn("n6", GetType(Integer)))

    'move array to datatable
    dim y as integer
    dim x as integer
    dim tot as integer
    for y = 1 to 594 step 6
    dr = dt.NewRow()
    for x = 0 to 5
    tot = x + y
    dr(x) = colArrayList(tot)
    next x
    dt.Rows.Add(dr)
    next y


    'list full dataset and then filtered dataset

    Dim foundRows As Datarow()
    dlistfull.DataSource = dt
    dlistfull.databind()
    'selected rows
    foundRows = dt.Select("n2 > 200")
    dlist5.DataSource = foundRows
    'the below lines telling me 'System.Data.DataRow' does not contain a
    'property with the name n4.
    dlist5.databind()

    ....

    </script>
    <form method="post" runat="server">
    <asp:dropdownlist id="dlistfull" datavaluefield="n2" Runat="server"/>
    <asp:dropdownlist id="dlist5" datavaluefield="n4" Runat="server"/>
    </form>


    Thanks for any help or information!
     
    , Nov 11, 2003
    #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. Fredrik Rodin

    Sort a datatable and create a new datatable

    Fredrik Rodin, Feb 16, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    9,100
    paul.mariotti
    Sep 28, 2007
  2. Nathan Sokalski

    Copying DataRows to another DataTable

    Nathan Sokalski, Nov 19, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    34,321
    jagdish.bhoir
    May 21, 2009
  3. Replies:
    5
    Views:
    480
    Luc The Perverse
    Oct 27, 2006
  4. tshad

    Datatable to a new DataTable

    tshad, Apr 12, 2007, in forum: ASP .Net
    Replies:
    0
    Views:
    284
    tshad
    Apr 12, 2007
  5. Nathan Sokalski

    Copying DataRows to another DataTable

    Nathan Sokalski, Nov 19, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    5
    Views:
    295
    PaulNaude
    Nov 22, 2005
Loading...

Share This Page