HierarGrid - A hierarchical DataGrid that displays master-detail relations


The ASP.NET DataGrid is a popular control to display data in a table form with editing, paging and sorting capabilites.
However it is only suitable to display single DataTables - there is no support for parent-child relations.


To create a control that provides the standard DataGrid functionality and at the same time can display parent-child relations using templates to display the child elements.


I have created a custom control called HierarGrid that derives from the DataGrid and a custom DataGridColumn called HierarColumn.

The HierarGrid takes a DataSet that contains relations between the tables.

While iterating over the parent table it checks the related tables for child rows and if one is found it dynamically loads a template for the child row(s).

The template is rendered invisibly into the custom HierarColumn and when the user clicks the plus icon, the template content is copied via JavaScript into a newly created TableRow.

Download (V2.2):

How to get started:


V2.2.0.0 (published 2006-05-12)

Bugfix: Under some conditions, UserControls still could not be reloaded when the application is configured as a website

V2.1.0.0 (published 2006-01-11)

Bugfix: UserControls could not be reloaded when the application is configured as a website (as opposed to virt.dir.) (thanks to Keith Culpepper)

Bugfix: fixed regression if ShowHeader=false and AllowPaging=false, colspan is wrong (thanks to Stuart Hilbert)

V2.0.0.0 (published 2005-12-18)

Bugfix: resolved compatibility issue with ASP.NET 2.0

V1.7.0.0 (published 2004-08-07)

Feature: TemplateDataMode.RunTime makes it possible to choose between SingleRow and Table for each relation at runtime (thanks to Tom Schmidt)

Feature: child templates are displayed for rows in selected state (thanks to Patrick Martin)

Bugfix: state of Checkboxes in child templates is now correctly preserved (thanks to Paolo Falabella)

Bugfix: corrected Mozilla DHTML incompatibilities (thanks to David T├ętreault)

V1.6.0.0 (published 2004-05-30)

Bugfix: corrected problem with non-unique IDs that were generated for "ChildTemplate" panel in a DataMode=Table HierarGrid

Bugfix: child templates were inserted into first column when PagerStyle was set to "Top"

Bugfix: resetting the DataItem after inserting the child templates for further custom processing

Bugfix: copying selected state for <select> tags

V1.5.0.0 (published 2003-10-17)

Feature: nested HierarGrids now possibly with more than 3 levels (thanks to Matt Petteys)

Bugfix: RowExpanded[x] = false was ignored

Bugfix: excluded RowExpanded property from Designer's Property view

Bugfix: changed Namespace for internal DynamicControlsPlaceholder to avoid conflicts when using both HierarGrid and DCP in one solution (thanks to Matt Bornstein)

V1.4.0.0 (published 2003-09-07)

Feature: keeps rowstate (expanded/collapsed) between postbacks

Feature: property "RowExpanded" to initially expand rows

Bugfix: HierarColumn not added to Columns collection

Bugfix: Exception with DataViews as DataSource and TemplateDataMode=Table

Bugfix: When TemplateDataMode=Table and DataSet.EnforceContraints=true an exception occured

Bugfix: Designer declaration corrected

V1.3.0.0 (published 2003-08-25)

Bugfix: corrected JavaScript to allow ShowHeader=False for the Grid

Bugfix: problem solved when TemplateDataMode=Table and DataSource was set to DataSet instead of DataTable

V1.2.0.0 (published 2003-04-26)

Feature: added support for Netscape and Opera

V1.1.0.0 (published 2003-04-25)

Feature: added support for nested HierarGrids
Bugfix: Exception when calling DataBind twice within one Request
Bugfix: Wrong PostData for TextBoxes in a child template

V1.0.0.0 (published 2003-03-04)

Initial version

Known Problems:


If you have any comments, suggestions or questions, feel free to drop me a line.