Binding Datagrids

B

brian

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()
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,817
Latest member
AdalbertoT

Latest Threads

Top