How do I bind a table/grid to a hierarchical DataSet with master-detail relationships?

Problem Statement

Present your users with a master-detail table, which they can explore to their desired level-of-detail by expanding or collapsing sub-tables.  Business records have regular fields (i.e., an order date, shipping date, and shipping address) and relationships across one- or more levels of depth (i.e., line item SKU, quantity, unit price, line total), perhaps summarized by sub-table (i.e., per-order total).

Your application retrieves these hierarchically related business records from a relational database (such as Microsoft SQL Server, Oracle, or IBM DB2) and is managing them through an ADO.NET DataSet containing two or more DataTables, and at least one DataRelation (between any "Master" and "Detail" tables).

Infragistics Solutions

ASP.NET     Windows Forms    
 

Locate the topmost "Master" table you want from the Tables collection of the DataSet, and assign this DataTable object to the WebGrid control's DataSource property.  Using the WebGrid with a ViewType of Hierarchical, set its DataSource property to this "Master" table.  When data binding, WebGrid will automatically traverse the DataRelations between DataTables within your DataSet to create the required hierarchical structure to be presented to your end users.

Expansion areas containing customizable [+] or [-] icons will appear on the WebGrid to allow users to expand or collapse sub-tables of information.  You can pre-expand specific rows programmatically with their Expanded property, or the ExpandAll method of the RowsCollection.

Other Solutions in the Data Binding Category

More Scenario Solutions...