Hello,
I try to create an DetailTable by Code.
My Code:
Databinding:
After Postback (any Postback - also any outside of the Grid) I get the following error:
[ArgumentOutOfRangeException: Der Index lag außerhalb des Bereichs. Er muss nicht negativ und kleiner als die Auflistung sein. Parametername: index] System.Collections.ArrayList.get_Item(Int32 index) +7483656 Telerik.WebControls.GridColumnCollection.System.Web.UI.IStateManager.LoadViewState(Object savedState) +199 Telerik.WebControls.GridTableView.LoadStructureState(Object SavedStructure) +229 Telerik.WebControls.RadGrid.LoadTableViewStructure(IEnumerator stateEnumerator, GridTableView tableView) +101 Telerik.WebControls.RadGrid.LoadTableViewStructure(IEnumerator stateEnumerator, GridTableView tableView) +358 Telerik.WebControls.RadGrid.LoadViewState(Object savedStateObject) +276 System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +183 System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +134 System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +221 System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +134 System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +221 System.Web.UI.Page.LoadAllState() +312 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1661
It sounds like the DetailTable looses its columns.
The DetailTable Creation I placed into the Page_Load (With or without PostBack).
Do I miss something to do?
Regards,
I try to create an DetailTable by Code.
My Code:
| GridRelationFields grf = new GridRelationFields(); |
| grf.DetailKeyField = "ris_per_id"; |
| grf.MasterKeyField = "per_id"; |
| GridTableView gridRis = new GridTableView(RadGrid1); |
| gridRis.DataKeyNames = new string[] { "ris_id" }; |
| gridRis.Name = "tblRis"; |
| gridRis.ParentTableRelation.Add(grf); |
| gridRis.EnableViewState = true; |
| gridRis.HierarchyDefaultExpanded = true; |
| GridBoundColumn colDetRis = new GridBoundColumn(); |
| colDetRis.UniqueName = "ris_id"; |
| colDetRis.DataField = "ris_id"; |
| colDetRis.HeaderText = "ID"; |
| colDetRis.Visible = false; |
| colDetRis.ReadOnly = true; |
| gridRis.Columns.Add(colDetRis); |
| GridButtonColumn edit = new GridButtonColumn(); |
| edit.ButtonType = GridButtonColumnType.ImageButton; |
| edit.CommandArgument = "edit"; |
| edit.CommandName = "detailaction"; |
| edit.ImageUrl = "../images/edit.png"; |
| gridRis.Columns.Add(edit); |
| RadGrid1.MasterTableView.DataKeyNames = new string[] { "per_id" }; |
| RadGrid1.MasterTableView.DetailTables.Add(gridRis); |
| gridRis.Rebind(); |
Databinding:
| protected void RadGrid1_NeedDataSource(object source, Telerik.WebControls.GridNeedDataSourceEventArgs e) |
| { |
| if (!e.IsFromDetailTable) |
| RadGrid1.DataSource = person.Data.DefaultView; |
| RadGrid1.MasterTableView.DetailTables[0].DataSource = ris.Data.DefaultView; // [0] = ris |
| } |
After Postback (any Postback - also any outside of the Grid) I get the following error:
[ArgumentOutOfRangeException: Der Index lag außerhalb des Bereichs. Er muss nicht negativ und kleiner als die Auflistung sein. Parametername: index] System.Collections.ArrayList.get_Item(Int32 index) +7483656 Telerik.WebControls.GridColumnCollection.System.Web.UI.IStateManager.LoadViewState(Object savedState) +199 Telerik.WebControls.GridTableView.LoadStructureState(Object SavedStructure) +229 Telerik.WebControls.RadGrid.LoadTableViewStructure(IEnumerator stateEnumerator, GridTableView tableView) +101 Telerik.WebControls.RadGrid.LoadTableViewStructure(IEnumerator stateEnumerator, GridTableView tableView) +358 Telerik.WebControls.RadGrid.LoadViewState(Object savedStateObject) +276 System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +183 System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +134 System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +221 System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +134 System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +221 System.Web.UI.Page.LoadAllState() +312 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1661
It sounds like the DetailTable looses its columns.
The DetailTable Creation I placed into the Page_Load (With or without PostBack).
Do I miss something to do?
Regards,