two views and a relation

  • Thread starter Thread starter WineNCheese
  • Start date Start date
W

WineNCheese

Hello,

I have a simple master-detail scenario, so I've set up the dataset with two
tables and a relation between them. When I have two data grids, one bound
to the master table's default view, the other bound to the relation,
navigation reacts as expected. However, I cannot seem to determine how to
modify the bindings to use a second DataView (it applies a simple filter)
for the master grid, while retaining the relation. I've determined the
DataView is filtering correctly, but I can't seem to get the binding
correct. Is there a way to do this?

In other words:

grid1.DataSource = ds.table1.DefaultView;
grid2.DataSource = ds'
grid2.DataMember = "table1.relation1"

works fine.

If I do the following:

grid1.DataSource = MyDataView;

How do I set the binding for grid2 so that the relation is maintained and
child records are displayed as per selection in grid1?

WNC
 
WNC,

To keep your DataGrids in synch, set their DataSource properties to
the same DataView, and set the child DataGrid's DataMember property to the
name of the DataRelation between your DataTables. Your code should look
like:

gridCustomers.DataSource = vueCustomers;
gridOrders.DataMember = "Customers_Orders";
gridOrders.DataSource = vueCustomers;

I hope this information proves helpful.

David Sceppa
Microsoft
This posting is provided "AS IS" with no warranties,
and confers no rights. You assume all risk for your use.
© 2004 Microsoft Corporation. All rights reserved.
 
Back
Top