Hierarchical Data Binding
In This Topic
C1GridView allows you to bind data in a hierarchical grid of summary rows and detail rows using your customized query. Hierarchical relationships are defined manually between multiple tables in C1DetailGridView. It enables you to display the hierarchical data with multilevel, multiple layouts and provide features such as sorting, filtering, grouping and editing.
The image below shows the hierarchical grid with one of its rows expanded.
Important Properties
- DataSourceID: Each grid must have its own data source to represent the data hierarchy in GridView. The data source for each detail grid view is set using the DataSourceID property.
-
DataKeyNames: The DataKeyNames property is used to identify a primary key for the C1GridView control. This property takes the name of fields from the connected database, as an array of strings. The primary key columns for each table in the datasource are added to the DataKeyNames property of the respective parent table or child table.
Source View |
Copy Code
|
<cc1:C1GridView runat="server" DataSourceID="SqlDataSource1" DataKeyNames="CustomerID, CompanyName">
|
- MasterDetailRelation: The MasterDetailRelation property is used to specify how data is linked between the detail or child table and the parent table. It allows you to link two different tables from the data source by specifying MasterDataKeyName and DetailDataKeyName property.
- MasterDataKeyName : The MasterDataKeyName property is used to set the relation between the parent and the child table. This property should be set to match the field specified in DataKeyNames for the parent table.
-
DetailDataKeyName : The DetailDataKeyName property is also used to set the relation between the child table and the parent table. It retrieves the data from the child table for the detail section. The field set as DetailDataKeyName should be the foreign key of the child table in the corresponding relation and it should also be a primary key in child table so that it matches with the field set as the MasterDataKeyName.
Source View |
Copy Code
|
<Relation>
<cc1:MasterDetailRelation MasterDataKeyName="CustomerID" DetailDataKeyName="CustomerID" />
</Relation>
|
- PageSize: The PageSize property can be set to define the number of rows to be displayed in the parent or child grid.
See Also