Master Detail using 2 Datagrids

P

Pocket Rocket

I am using 2 data grids to display master detail relatioships in a database.
I would like to findout how I can setup the datasource and datamember of the
grids to get this accomplished. The way I tried did not work:

grid1.datasource = this.dataset1;
grid1.datamembar = "parenttable";
grid2.datasource = this.dataset2;
grid2.datamember = "parenttable.parentchildrelation.childtable";

where paranttable and childtable are the names of parent and child tables
and parentchildrelation is the name of the one to many relationship between
the parent and child tables.


Thanks
PR
 
D

David Sceppa

PR,

Your code should look something like this:

grid1.DataSource = this.dataset1;
grid1.DataMember = "parenttable";
grid2.DataSource = this.dataset1;
grid2.DataMember = "parenttable.parentchildrelation";

Each grid should be bound to the same DataSet. Set the parent grid's
DataMember property to the name of the parent table. Set the child grid's
DataMember property to the name of the parent table, followed by a ".",
followed by the name of the DataRelation.

As you navigate through the rows in parent table in the parent grid,
you should see the corresponding child rows in the child grid.

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.
 
R

r

You might check this out also...
ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/vbcon/html/vbwlkwalkthroughcreatingmaster-detailwindowsform.htm
r
 

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