I have a datagrid with hierarchical data that I want to populate not using the SqlDataSource reference but from the code behind cs.
I can populate the root data table but not sure how I go about populating the sub tables of the datagrid.
From aspx:
<telerik:RadGrid ID="rgrid_Data" runat="server" AllowPaging="True" AutoGenerateColumns="False" ShowGroupPanel="True" OnItemDataBound="rgrid_Data_ItemDataBound">
<MasterTableView AutoGenerateColumns="false">
<Columns>
<telerik:GridBoundColumn HeaderText="Month" DataField="item" UniqueName="item"></telerik:GridBoundColumn>
</Columns>
<DetailTables>
<telerik:GridTableView AutoGenerateColumns="false" DataKeyNames="item" >
<ParentTableRelation>
<telerik:GridRelationFields DetailKeyField="StartMonth" MasterKeyField="item" />
</ParentTableRelation>
<Columns>
<telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName= "DeleteColumn"></telerik:GridButtonColumn>
<telerik:GridButtonColumn CommandName="Update" Text="Update" UniqueName= "UpdateColumn"></telerik:GridButtonColumn>
<telerik:GridBoundColumn HeaderText="ID" DataField="Id" UniqueName= "Id"></telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="Start Date" DataField="StartDate" UniqueName= "StartDate"></telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="Expiry Date" DataField="ExpiryDate" UniqueName= "ExpiryDate"></telerik:GridBoundColumn>
</Columns>
</telerik:GridTableView>
</DetailTables>
</MasterTableView>
</telerik:RadGrid>
So to populate the root dataset I've been using
this.rgrid_Data.DataSource = dataSet;
this.rgrid_Data.DataBind();
and in trying to populate the sub sections I've been going down the path
this.rgrid_Data.MasterTableView.DetailTables[0].DataSource = subDataSet;
this.rgrid_Data.MasterTableView.DetailTables[0].DataBind();
Any help, much appreciated.
I can populate the root data table but not sure how I go about populating the sub tables of the datagrid.
From aspx:
<telerik:RadGrid ID="rgrid_Data" runat="server" AllowPaging="True" AutoGenerateColumns="False" ShowGroupPanel="True" OnItemDataBound="rgrid_Data_ItemDataBound">
<MasterTableView AutoGenerateColumns="false">
<Columns>
<telerik:GridBoundColumn HeaderText="Month" DataField="item" UniqueName="item"></telerik:GridBoundColumn>
</Columns>
<DetailTables>
<telerik:GridTableView AutoGenerateColumns="false" DataKeyNames="item" >
<ParentTableRelation>
<telerik:GridRelationFields DetailKeyField="StartMonth" MasterKeyField="item" />
</ParentTableRelation>
<Columns>
<telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName= "DeleteColumn"></telerik:GridButtonColumn>
<telerik:GridButtonColumn CommandName="Update" Text="Update" UniqueName= "UpdateColumn"></telerik:GridButtonColumn>
<telerik:GridBoundColumn HeaderText="ID" DataField="Id" UniqueName= "Id"></telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="Start Date" DataField="StartDate" UniqueName= "StartDate"></telerik:GridBoundColumn>
<telerik:GridBoundColumn HeaderText="Expiry Date" DataField="ExpiryDate" UniqueName= "ExpiryDate"></telerik:GridBoundColumn>
</Columns>
</telerik:GridTableView>
</DetailTables>
</MasterTableView>
</telerik:RadGrid>
So to populate the root dataset I've been using
this.rgrid_Data.DataSource = dataSet;
this.rgrid_Data.DataBind();
and in trying to populate the sub sections I've been going down the path
this.rgrid_Data.MasterTableView.DetailTables[0].DataSource = subDataSet;
this.rgrid_Data.MasterTableView.DetailTables[0].DataBind();
Any help, much appreciated.
