I'm following along with the "Grid - Hierarchy with Templates" example. There's a parent table, when the parent table row is expanded a template with several tabs is displayed, each tab contains a sub grid of the parent. For the most part my version of this example works great.
The example seems to use "a little magic" to communicate the data key for the parent rows to the controls in the NestedViewTemplate. An ASP Label's text is bound to the data key for the rows (it is set not visible). A reference to the magic Label is then used in the ObjectDataSource to fetch sub grid data as needed.
My issues relates to having to do some validation of data before new data is Inserted. To do the validation I need to know the parent table row's data key in the code behind from the magic Label. I know how to get the Label's for all rows such as in the code example below. My issue is figuring out which Label to take the key from as there's a Label for each row in the Parent table.
protected void BudgetAdjustmentItemRadGrid_InsertCommand(object sender, GridCommandEventArgs e)
Label dataKeyLabel = null;
int id = 0;
foreach (GridNestedViewItem item1 in ParentRadGrid.MasterTableView.GetItems(GridItemType.NestedView))
dataKeyLabel = (Label)item1.FindControl("DataKeyLabel");
if (dataKeyLabel != null)
id = Convert.ToInt32(dataKeyLabel.Text);
Maybe there's a better way to get the parent table row's data key. Let me know if you know one. I did find something that looked promising in the documentation. There's reference to a Parent Data Key and Detail Data Key such as below. However I can't find a working example of these settings. Furthermore my app won't compile when I attempt to use them.
<NestedViewSettings DataSourceID="SqlDataSource2"><telerik:ParentTableRelation MasterKeyField="CustomerID" DetailKeyField="CustomeriD"/></NestedViewSettings>