This is a migrated thread and some comments may be shown as answers.

[Solved] DataSet with MasterTable and DetailTable

1 Answer 128 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 19 Jun 2009, 07:42 PM
I've got a DataSet with 2 tables that have a relationship between them assigned in the DataSet:

i.e.
DataSet ds = new DataSet();
ds.Tables.Add(customerTable);
ds.Tables.Add(orderTable);
DataColumn parentDC = customerTable.Columns["CustomerID"];
DataColumn childDC = orderTable.Columns["CustomerID"];
ds.Relations.Add("Customer_Orders", parentDC, childDC, false);

My Grid has a MasterTable and DetailTable setup, with the appropriate ParentTableRelation setup.

I was hoping that I could simply set the datasource of the grid to this dataset (the master getting the first datatable, and the detail getting the second), and that the relationship would be used in the DetailTable to filter on expanding, but that does not appear to be the case. Is this possible, and if so, are thre any live examples on the net?

Thanks.

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 22 Jun 2009, 08:02 AM
Hi Matt,

I would suggest you to use the DetailTableDataBind event to populate the child Grid. You may set the 'CustomerID' as the DataKeyName for both Master and Detail table. In the DetailTableDataBind event you may access the key value for the parent row and populate the child table accordingly.

Refer the following demo link for getting more details on Programmatic Binding of heirarchical Grid.
Programmatic Binding

Shinu

Tags
Grid
Asked by
Matt
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or