KB Article A1232
Visible to All Users

Can the grid display data from several data tables in a single grid view?

Description:
I have a data set that holds multiple data tables. I want to show these tables in a single grid view (like a join). Can I do this by simply binding the XtraGrid to the DataSet? How can I tell a grid that it should display the columns from several tables?

Answer:
The XtraGrid, as with many other data controls, can be bound to a single data source object. Therefore, you should create such an object yourself based on the tables that you want to display. There are two possible solutions:

  1. Produce a single table by combining the result set of two queries with the INNER JOIN SQL query. Here is some sample code:
SQL
SELECT Products.*, Categories.* FROM Products INNER JOIN Categories ON Products.CategoryID = Categories.CategoryID
  1. Use the JoinView class from Microsoft Knowledge Base or create your own wrapper class for your dataset. Your wrapper class must implement the IList and ITypedList interfaces. IList provides access to rows and ITypedList defines columns.
  2. Use the XPView component from the eXpress Persistent Objects.
    See Also:
    How to display and edit complex data properties in grid columns

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.