Binding Datagrids

Discussion in 'ASP .Net' started by brian, Jan 29, 2004.

  1. brian

    brian Guest

    Can you bind a datarelation to a datagrid? I posted my
    code below. I built a datarelation with "Users" as
    parent and "Computer" as child to create a table
    called "Info" in dataset "ds".

    I bind my datagrid to the datarelation table "Info" but
    the datagrid shows up empty. I debugged the "Info" table
    and it shows no records.

    The purpose of this is that I need the child table to
    display actual text data in the data grid instead of a
    number. I can't do a normal query because the two tables
    I need are in two different databases.

    Thanks for any help!

    'Build datareation
    Dim drn As DataRelation
    Dim dcParent As DataColumn
    Dim dcChild As DataColumn

    dcParent = ds.Tables("Users").Columns("UserID")
    dcChild = ds.Tables("Computer").Columns("c_users")

    drn = New DataRelation("Info", dcParent, dcChild)
    ds.Relations.Add(drn)

    DataGrid1.DataSource = ds.Tables("Info")
    DataGrid1.DataBind()
    brian, Jan 29, 2004
    #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. Eldon Ferran de Pol

    Binding Datagrids To a collection

    Eldon Ferran de Pol, Dec 4, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    319
    Anatoly
    Dec 4, 2003
  2. Jim Bancroft
    Replies:
    3
    Views:
    1,876
    Bob Weiner
    May 2, 2005
  3. joe data

    Binding multiple datagrids to the same datasource

    joe data, Apr 27, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    417
    joe data
    Apr 27, 2004
  4. Jim Bancroft

    binding ArrayLists to DataGrids-- how to name the columns?

    Jim Bancroft, Apr 30, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    3
    Views:
    129
    Bob Weiner
    May 2, 2005
  5. Colin Basterfield

    binding DataGrids to a Custom Collection

    Colin Basterfield, Jan 6, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    116
    Colin Basterfield
    Jan 6, 2004
Loading...

Share This Page