This is a migrated thread and some comments may be shown as answers.

[Solved] Throw PageRequestManagerServerErrorException while Postback.

1 Answer 206 Views
Grid
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 23 Jun 2008, 02:33 AM

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.

1 Answer, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 25 Jun 2008, 08:27 AM
Hello John ,

Based on the code snippet provided, I suspect that the exception is caused by the improper declaration of the structure. The following example demonstrates a working example. Additionally, I would suggest that you take advantage of a DetailTableDataBind handler, to provide data to the inner levels of the hierarchy.
I hope this information helps.

Sincerely yours,
Yavor
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
Grid
Asked by
John
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Share this question
or