Hi,
I build a GridTableView programmatically and add this GridTableView
to the collection of detail table views for the RadGrid to display
related data tables hierarchically. But when I click the expand button
and the edit command button, I got an exception,
Sys.WebForms.PageRequestManagerServerErrorException
My code as follows:
if (!this.IsPostBack)
{
// Get related data tables: Customers table and Projects table
DataTable dtblCust = Datahandler.Datahandler.GetCustomer();
DataTable dtblProj = Datahandler.Datahandler.GetCustProj();
ViewState["Cust"] = dtblCust;
ViewState["Proj"] = dtblProj;
// Create a GridTableView
GridTableView gtvProj = new GridTableView();
string[] sTep = new string[1];
sTep[0] = "ProjectInfoID";
gtvProj.DataKeyNames = sTep;
// Add ParentTableRelation to the GridTableView
GridRelationFields grfTep = new GridRelationFields();
grfTep.DetailKeyField = "CustomerInfoID";
grfTep.MasterKeyField = "CustomerInfoID";
gtvProj.ParentTableRelation.Add(grfTep);
// Build columns of the GridTableView
GridBoundColumn gbcTep = new GridBoundColumn();
gbcTep.HeaderText = "Project ID";
gbcTep.DataField = "ProjectInfoID";
gbcTep.UniqueName = "ProjectInfoID";
gbcTep.SortExpression = "ProjectInfoID";
gtvProj.Columns.Add(gbcTep);
gbcTep = new GridBoundColumn();
gbcTep.HeaderText = "Project Name";
gbcTep.DataField = "ProName";
gbcTep.UniqueName = "ProName";
gbcTep.SortExpression = "ProName";
gtvProj.Columns.Add(gbcTep);
gbcTep = new GridBoundColumn();
gbcTep.HeaderText = "Create Day";
gbcTep.DataField = "CreateDay";
gbcTep.UniqueName = "CreateDay";
gbcTep.SortExpression = "CreateDay";
gtvProj.Columns.Add(gbcTep);
// Add EditCommandColumn to the GridTableView
GridEditCommandColumn geccTep = new GridEditCommandColumn();
geccTep.UniqueName = "EditCommandColumn";
geccTep.EditText = "Edit";
geccTep.ItemStyle.Width = 100;
gtvProj.Columns.Add(geccTep);
// Add SortExpressions to the GridTableView
GridSortExpression gseTep = new GridSortExpression();
gseTep.FieldName = "ProjectInfoID";
gseTep.SortOrder = GridSortOrder.Ascending;
gtvProj.SortExpressions.Add(gseTep);
// Add the GridTableView to the collection of detail table views for the RadGrid
RadGrid1.MasterTableView.DetailTables.Add(gtvProj);
RadGrid1.DataSource = dtblCust;
RadGrid1.MasterTableView.DetailTables[0].DataSource = dtblProj;
RadGrid1.SelectedIndexes.Add(1, 0, 1);
}
Bestregards.