two views and a relation

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
 
D

David Sceppa

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.
 

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