We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Master-child DataBoundGrids

I have a dataset which contains 2 tables (A+B) which are joined. I set the data source of 2 datagrids to this dataset. Grid A has a data member of A. Grid B has a data member of B. Why isn''t there a ''parent''-''child'' relationship set up? i.e. I want to click on id 1 in grid A and ONLY records associated with id 1 appear in B. How can I set this up? Thanks, Dan

3 Replies

AD Administrator Syncfusion Team August 4, 2005 06:43 PM

You need to add the two datatables to a DataSet and then define a Relation between a column in the master datatable to a column in the detail table, and add this relation to the DataSet. This process is discussed in the GridDataBoundGrid Use Case section of the grid''s User''s Guide. Here is some code that is posted there. private void Form1_Load(object sender , System.EventArgs e) { //Fill the dataset with the two tables. this.sqlDataAdapter1.Fill(this.dataSet11.Customers); this.sqlDataAdapter2.Fill(this.dataSet11.Orders); //Add a DataRelation to the dataset. DataRelation dr = new DataRelation("CustomersToOrders", this.dataSet11.Customers.Columns["CustomerID"], this.dataSet11.Orders.Columns["CustomerID"]); this.dataSet11.Relations.Add(dr); //Set up the datasources. this.masterGrid.DataSource = this.dataSet11.Tables["Customers"]; this.detailsGrid.DataSource = Me.DataSet11.Tables["Customers"]; this.detailsGrid.DataMember = "CustomersToOrders"; }


DC dan carr August 5, 2005 10:03 AM

Thanks Clay. This worked. One other request: do you have an example which shows how to add records to parent/child grids. I can only find examples which show displaying info. Thanks, Dan


AD Administrator Syncfusion Team August 5, 2005 10:44 AM

Here is a forum thread that I think has a sample showing what you want. http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=16124

Loader.
Live Chat Icon For mobile
Up arrow icon