Product Bundles
DevCraft
All Telerik .NET tools and Kendo UI JavaScript components in one package. Now enhanced with:
Web
Mobile
Document Management
Desktop
Reporting
Testing & Mocking
CMS
UI/UX Tools
Debugging
Free Tools
Support and Learning
Productivity and Design Tools
private void DefineGridStructure() { RadGrid RadGrid1 = new RadGrid(); RadGrid1.ID = "RadGrid1"; RadGrid1.MasterTableView.DataKeyNames = new string[] { "CustomerID" }; RadGrid1.MasterTableView.Name = "Customers"; //Add columns //Detail table - Orders (II in hierarchy level) GridTableView tableViewOrders = new GridTableView(RadGrid1); tableViewOrders.Name = "Orders"; // Name of the child grid tableViewOrders.DataKeyNames = new string[] { "OrderID" }; GridRelationFields relationFields = new GridRelationFields(); relationFields.MasterKeyField = "CustomerID"; relationFields.DetailKeyField = "CustomerID"; tableViewOrders.ParentTableRelation.Add(relationFields); RadGrid1.MasterTableView.DetailTables.Add(tableViewOrders); //Add columns boundColumn = new GridBoundColumn(); boundColumn.DataField = "OrderID"; boundColumn.HeaderText = "OrderID"; boundColumn.UniqueName = "OrderID"; tableViewOrders.Columns.Add(boundColumn); } void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridDataItem && e.Item.OwnerTableView.Name == "Orders") //Name of child grid { GridDataItem dataItem = (GridDataItem)e.Item; TableCell cell = dataItem["OrderID"];//Accessing Cell value of Detail Table using UniqueName string itemValue = dataItem["OrderID"].Text; } }
private
void
DefineGridStructure()
{
RadGrid RadGrid1 =
new
RadGrid();
RadGrid1.ID =
"RadGrid1"
;
RadGrid1.MasterTableView.DataKeyNames =
string
[] {
"CustomerID"
};
RadGrid1.MasterTableView.Name =
"Customers"
//Add columns
//Detail table - Orders (II in hierarchy level)
GridTableView tableViewOrders =
GridTableView(RadGrid1);
tableViewOrders.Name =
"Orders"
// Name of the child grid
tableViewOrders.DataKeyNames =
"OrderID"
GridRelationFields relationFields =
GridRelationFields();
relationFields.MasterKeyField =
relationFields.DetailKeyField =
tableViewOrders.ParentTableRelation.Add(relationFields);
RadGrid1.MasterTableView.DetailTables.Add(tableViewOrders);
boundColumn =
GridBoundColumn();
boundColumn.DataField =
boundColumn.HeaderText =
boundColumn.UniqueName =
tableViewOrders.Columns.Add(boundColumn);
}
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
if
(e.Item
is
GridDataItem && e.Item.OwnerTableView.Name ==
)
//Name of child grid
GridDataItem dataItem = (GridDataItem)e.Item;
TableCell cell = dataItem[
];
//Accessing Cell value of Detail Table using UniqueName
itemValue = dataItem[
].Text;