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:
- Produce a single table by combining the result set of two queries with the INNER JOIN SQL query. Here is some sample code:
SQLSELECT Products.*, Categories.* FROM Products
INNER JOIN Categories ON Products.CategoryID = Categories.CategoryID
- 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.
- Use the XPView component from the eXpress Persistent Objects.
See Also:
How to display and edit complex data properties in grid columns