KB Article A378
Visible to All Users

How to Display Master-Detail Tables in Separate Grid Controls

Description:
How to display master-detail tables in two different grids? A master table should be displayed in one GridControl. Another GridControl should contain details for the selected master row in the first grid.

Answer:
The most popular way to visualize Master-Detail tables in an XtraGrid is by displaying the detail data embedded into master rows that then expand to show the detail view. However, sometimes it may be desirable to display the detail data in a Grid control of it's own, and as you navigate through the master data in a master grid the detail data in the detail grid displays all the related detail controls for the selected master record.
It is easy to implement this, if you are using an ADO.NET dataset (System.Data.DataSet). The GridControl object intended for displaying the detail data should be bound to an ADO.NET data relation. Please look at the attached sample. The DataMember property of GridControl2 is the name of a data relation for the Customers table, which is assigned to the DataSource property.

Visual Basic
' Bind to a relation GridControl2.DataSource = DataSet11.Customers GridControl2.DataMember = "CustomersOrders"

If you are using a third-party data object or you have built your own, and it can contain master-detail data like System.Data.DataSet then you will probably be able to bind it's detail data to an XtraGrid as shown above.
See Also:
How to use two XtraGrid controls to display collections of persistent objects with a one-to-many association

Comments (2)

    Do you have any solution for the same scenario with ViewModel binding in WPF Xpf.GridControl ?

    DevExpress Support Team 12 years ago

      Hi,
      I have extracted your inquiry to a separate ticket and passed it to our WPF team. Please refer to the Q375292 thread.

      Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

      Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.