When I edit the grid shows me the following error.
I'm trying to create as many columns as there are data in thedatabase. And the only way I can create the template editing is by using the "autogenerated"
But whenever I have the same problem. I've tried so many ways to fix it but I can not think of anything.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: index
Stack Trace:
All columns are inserted from C# code. The reason is that thenumber of columns depends on the number of fields in thedatabase.
And ASPX
Thanks!
I'm trying to create as many columns as there are data in thedatabase. And the only way I can create the template editing is by using the "autogenerated"
But whenever I have the same problem. I've tried so many ways to fix it but I can not think of anything.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: index
Stack Trace:
[ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: index] System.Web.UI.ControlCollection.get_Item(Int32 index) +8690450 Telerik.Web.UI.GridTextBoxColumnEditor.LoadControlsFromContainer() +70 Telerik.Web.UI.GridColumnEditorBase.InitializeFromControl(Control containerControl) +50 Telerik.Web.UI.GridEditFormItem.InitializeEditorInCell(IGridEditableColumn column) +1083 Telerik.Web.UI.GridEditManager.GetColumnEditor(IGridEditableColumn column) +175 Telerik.Web.UI.GridBoundColumn.FillValues(IDictionary newValues, GridEditableItem editableItem) +82 Telerik.Web.UI.GridEditableItem.ExtractValues(IDictionary newValues) +164 Telerik.Web.UI.GridEditFormItem.ExtractValues(IDictionary newValues) +169 Telerik.Web.UI.GridTableView.ExtractValuesFromItem(IDictionary newValues, GridEditableItem editedItem) +115 Telerik.Web.UI.GridItemBuilder.CreateItems(GridGroupingContext group) +1037 Telerik.Web.UI.GridTableView.CreateItems(IEnumerator enumerator, GridColumn[] columns, ControlCollection controls) +193 Telerik.Web.UI.GridTableView.CreateControlHierarchy(Boolean useDataSource) +1607 Telerik.Web.UI.GridTableView.CreateChildControls(IEnumerable dataSource, Boolean useDataSource) +802 System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() +161 System.Web.UI.Control.EnsureChildControls() +102 Telerik.Web.UI.GridTableViewBase.get_Controls() +33 System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +24 System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +225 System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +148 System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +225 System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +148 System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +225 System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +148 System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +225 System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +148 System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +225 System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +148 System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +225 System.Web.UI.Page.LoadAllState() +312 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +747 |
All columns are inserted from C# code. The reason is that thenumber of columns depends on the number of fields in thedatabase.
protected
void
uxrdgrid_Deficiencias_NeedDataSource(
object
source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
DaoDeficiencias servicioDeficiencias =
new
DaoDeficiencias();
DaoMetodoRehabilitacion servicioMetodoRehabilitacion =
new
DaoMetodoRehabilitacion();
DaoDeficienciaMetodoRehabilitacion servicioDefienciaMetodoRehabilitacion =
new
DaoDeficienciaMetodoRehabilitacion();
DaoTipoValidezMetodoRehabilitacion servicioTipoValidezMetodoRehabilitacion =
new
DaoTipoValidezMetodoRehabilitacion();
IList listaDeficiencias = servicioDeficiencias.ObtenerTodos();
IList listaMetodosRehabilitacion = servicioMetodoRehabilitacion.ObtenerTodos();
IList listaDeficienciaMetodoRehabilitacion = servicioDefienciaMetodoRehabilitacion.ObtenerTodos();
IList listaTipoValidezMetodoRehabilitacion = servicioTipoValidezMetodoRehabilitacion.ObtenerTodos();
GridTableView tableview =
new
GridTableView(uxrdgrid_Deficiencias);
GridColumnCollection coleccionColumnas =
new
GridColumnCollection(tableview);
List<ListDictionary> listaDataSource =
new
List<ListDictionary>();
GridDropDownColumn column;
DataTable tablaDatos =
new
DataTable();
DataColumn columnaDatos;
DataRow filaDatos;
uxrdgrid_Deficiencias.Columns.Clear();
GridBoundColumn columnBound =
new
GridBoundColumn();
columnBound.DataField =
"Codigo_deficiencia"
;
columnBound.UniqueName =
"Codigo_deficiencia"
;
columnBound.HeaderText =
"Código Deficiencia"
;
columnBound.ReadOnly =
true
;
columnBound.ShowFilterIcon =
false
;
columnBound.AllowSorting =
true
;
uxrdgrid_Deficiencias.Columns.Add(columnBound);
GridTextBoxColumnEditor GridTextBoxColumnEditor1 =
new
GridTextBoxColumnEditor();
GridTextBoxColumnEditor1.ID =
"GridTextBoxColumnEditor1"
;
GridDropDownListColumnEditor GridDropDownListColumnEditor1 =
new
GridDropDownListColumnEditor();
GridDropDownListColumnEditor1.ID =
"GridDropDownListColumnEditor1"
;
columnaDatos =
new
DataColumn();
columnaDatos.DataType = Type.GetType(
"System.String"
);
columnaDatos.ColumnName =
"Codigo_deficiencia"
;
tablaDatos.Columns.Add(columnaDatos);
foreach
(T_METODO_REHABILITACION metodoRehabilitacion
in
listaMetodosRehabilitacion)
{
column =
new
GridDropDownColumn();
column.AllowFiltering =
false
;
column.DataSourceID = tiposValidezMetodoDataSource.ID;
column.HeaderText = metodoRehabilitacion.Nombre;
column.DataField = (
"Validez."
+ metodoRehabilitacion.Nombre).Trim();
column.UniqueName = (
"Validez."
+ metodoRehabilitacion.Nombre).Trim();
column.ListValueField =
"Id"
;
column.ListTextField =
"Nombre"
;
uxrdgrid_Deficiencias.Columns.Add(column);
columnaDatos =
new
DataColumn();
columnaDatos.DataType = Type.GetType(
"System.Int32"
);
columnaDatos.ColumnName = (
"Validez."
+ metodoRehabilitacion.Nombre).Trim();
tablaDatos.Columns.Add(columnaDatos);
}
foreach
(T_DEFICIENCIA deficienciaItem
in
listaDeficiencias)
{
filaDatos = tablaDatos.NewRow();
filaDatos[
"Codigo_deficiencia"
] = deficienciaItem.Codigo;
foreach
(T_METODO_REHABILITACION metodRehaItem
in
listaMetodosRehabilitacion)
{
foreach
(T_DEFICIENCIA_METODO_REHABILITACION defMetRehItem
in
listaDeficienciaMetodoRehabilitacion)
{
if
(defMetRehItem.Deficiencia.Id == deficienciaItem.Id && defMetRehItem.MetodoRehabilitacion.Id == metodRehaItem.Id)
{
filaDatos[(
"Validez."
+ defMetRehItem.MetodoRehabilitacion.Nombre).Trim()] = defMetRehItem.Validez.Id;
}
}
}
tablaDatos.Rows.Add(filaDatos);
}
uxrdgrid_Deficiencias.DataSource = tablaDatos;
}
And ASPX
<telerik:RadCodeBlock ID=
"RadCodeBlock1"
runat=
"server"
>
<script type=
"text/javascript"
>
function EditRow(sender, eventArgs) {
sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
}
</script>
</telerik:RadCodeBlock>
<asp:Label ID=
"Label4"
runat=
"server"
CssClass=
"PageTitle"
>Métodos de rehabilitación segun deficiencias</asp:Label>
<telerik:RadGrid ID=
"uxrdgrid_Deficiencias"
runat=
"server"
AllowFilteringByColumn=
"False"
AllowSorting=
"True"
AllowPaging=
"True"
PageSize=
"15"
GridLines=
"None"
width=
"100%"
Skin=
"Vista"
AllowAutomaticDeletes=
"False"
AllowAutomaticInserts=
"False"
AllowAutomaticUpdates=
"False"
onneeddatasource=
"uxrdgrid_Deficiencias_NeedDataSource"
ondeletecommand=
"uxrdgrid_Deficiencias_DeleteCommand"
oninsertcommand=
"uxrdgrid_Deficiencias_InsertCommand"
onupdatecommand=
"uxrdgrid_Deficiencias_UpdateCommand"
onitemcommand=
"uxrdgrid_Deficiencias_ItemCommand"
>
<ClientSettings EnableRowHoverStyle=
"false"
AllowKeyboardNavigation=
"true"
>
<Selecting AllowRowSelect=
"True"
/>
<ClientEvents OnRowDblClick=
"EditRow"
/>
<KeyboardNavigationSettings EnableKeyboardShortcuts=
"true"
AllowActiveRowCycle=
"true"
/>
</ClientSettings>
<GroupingSettings CaseSensitive=
"false"
/>
<MasterTableView AutoGenerateColumns=
"False"
DataKeyNames=
"Codigo_deficiencia"
ClientDataKeyNames=
"Codigo_deficiencia"
EditMode=
"PopUp"
CommandItemDisplay=
"Bottom"
>
<CommandItemSettings AddNewRecordText=
"Añadir nuevo registro"
RefreshText=
"Refrescar"
/>
<EditFormSettings InsertCaption=
"Crear nuevo Detalle de Inspección"
CaptionFormatString=
"Editar Detalle de Inspección: {0}"
CaptionDataField=
"Codigo_Deficiencia"
EditColumn-CancelText=
"Cancelar"
EditColumn-Display=
"True"
EditFormType=
"AutoGenerated"
>
<FormCaptionStyle CssClass=
"EditFormHeader"
></FormCaptionStyle>
<FormMainTableStyle GridLines=
"None"
CellSpacing=
"5"
CellPadding=
"3"
Width=
"100%"
/>
<FormTableStyle CellSpacing=
"0"
CellPadding=
"2"
Height=
"60px"
/>
<EditColumn ButtonType=
"ImageButton"
InsertText=
"Guardar"
UpdateText=
"Guardar cambios"
UniqueName=
"EditCommandColumn1"
CancelText=
"Cancelar edición"
>
</EditColumn>
<FormTableButtonRowStyle HorizontalAlign=
"Right"
CssClass=
"EditFormButtonRow"
></FormTableButtonRowStyle>
<PopUpSettings Modal=
"True"
Width=
""
></PopUpSettings>
</EditFormSettings>
</MasterTableView>
</telerik:RadGrid>
<asp:ObjectDataSource ID=
"tiposValidezMetodoDataSource"
runat=
"server"
OldValuesParameterFormatString=
"original_{0}"
SelectMethod=
"ObtenerTodos"
TypeName=
"Aquatec.MetresaWeb.Web.DaoServices.DaoTipoValidezMetodoRehabilitacion"
>
</asp:ObjectDataSource>
Thanks!