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.
Unfortunately, activation email could not send to your email. Please try again.

Master-child DataBoundGrids

Thread ID:

Created:

Updated:

Platform:

Replies:

32649 Aug 4,2005 07:22 PM Aug 5,2005 11:44 AM Windows Forms 3
loading
Tags: GridControl
dan carr
Asked On August 4, 2005 07:22 PM

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

Administrator [Syncfusion]
Replied On August 4, 2005 07: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"; }

dan carr
Replied On August 5, 2005 11: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

Administrator [Syncfusion]
Replied On August 5, 2005 11: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

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;