Data Relation Advice

C

Christopher Weaver

I have a DataSet with two tables and a DataRelation. When I populate the
DataSet and define a master detail relationship through the DataRelation,
the grid bound to the master table shows both the master and detail rows
while the grid bound to the detail table shows the detail rows for all of
the master table rows. I would like the grid bound to the detail table to
show the detail rows related to the each master row as the user moves
through the master rows. I know I could do this with a currency manager and
an event hander, but that doesn't seem right. Surely I'm overlooking
something fairly simple that makes this work.

Thanks.
 
N

Nicholas Paldino [.NET/C# MVP]

Christopher,

Instead of binding the details table to the child table, bind it to the
relation itself, and it should do what you want.

Hope this helps.
 
C

Christopher Weaver

Do you mean binding the details DataGrid to the DataRelation? The compiler
coughs that up. I've tried setting the DataSource property to
DataRelation.ChildTable, but that gives me the same result.

Also, when you 'binding', is this the same as setting the DataSource
property? I've tried that and I've also tried using
SetDataBinding(DataRelation, StringTableName) and SetDataBinding(DataSet,
StringTableName). The first one fails altogether ("Cannot produce a child
list for field <TableName>") while the second compiles and runs but produces
all of the child rows for the rows present in the parent table.

Thanks for any help.


Nicholas Paldino said:
Christopher,

Instead of binding the details table to the child table, bind it to the
relation itself, and it should do what you want.

Hope this helps.


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Christopher Weaver said:
I have a DataSet with two tables and a DataRelation. When I populate the
DataSet and define a master detail relationship through the DataRelation,
the grid bound to the master table shows both the master and detail rows
while the grid bound to the detail table shows the detail rows for all of
the master table rows. I would like the grid bound to the detail table to
show the detail rows related to the each master row as the user moves
through the master rows. I know I could do this with a currency manager
and an event hander, but that doesn't seem right. Surely I'm overlooking
something fairly simple that makes this work.

Thanks.
 

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

Top