Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
116 views
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:

[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!

Radoslav
Telerik team
 answered on 18 Apr 2011
1 answer
64 views
Hello,

I am using a same grid for the different datasources. I want there non of the row will be double lined. I used  ItemStyle-Wrap="false" but was not useful.
Pavlina
Telerik team
 answered on 18 Apr 2011
1 answer
84 views
Hi,

I am new to telerik controls. It seems really good an I have been evaluating it for use in a project I am working on. The client is really impressed with the look/feel/design. But before I can get him to purchase it I need to be sure I can achieve all the results needed. There is only 1 problem, I am unable to get downloads from a grid working. Below is the code I am using to run the download command. The problem is the choose location dialogue box never appear when I click the download link. I need to mention here that the download link is in a nested grid (grid inside a master grid). Could this be the problem? How do I overcome this?

//Code for inner grid. The event is grid_itemcommand()
void gvReceipt_ItemCommand(object source, GridCommandEventArgs e)
    {
        if (e.CommandName == "Download")
        {
         var ExpHeader_ID = (int)((GridEditableItem)e.Item).GetDataKeyValue("ExpenseHeaderID");
            Int32 ExpID = Convert.ToInt32(ExpHeader_ID);
            ExpHeaderIdReceipt = ExpID;
        
            GridDataItem dataItem = (GridDataItem)e.Item;
            Label lblImgeName = (Label)dataItem.FindControl("lblImage");
            string strRequest = lblImgeName.Text;
            if (!string.IsNullOrEmpty(strRequest))
            {
                string path = Server.MapPath(Manage_FilePaths.HeaderExpImagesRootPath_Original 
+ strRequest);
                System.IO.FileInfo file = new System.IO.FileInfo(path);
                
                if (file.Exists)
                {
                    Response.Clear();
                    Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
                    Response.AddHeader("Content-Length", file.Length.ToString());
                    Response.ContentType = "application/octet-stream";
                    Response.WriteFile(file.FullName);
                    Response.End();
                }
                else
                {
                    Response.Write("This file does not exist.");
                }
            }
            else
            {
                ScriptManager.RegisterStartupScript(this.updGrids, typeof(string), "alert", "<script>alert('Please provide a file to download!');</script>", false);
            }
        }
    }
Radoslav
Telerik team
 answered on 18 Apr 2011
5 answers
197 views
Is there a way to change the value of Yaxis major tick labels once the graph is established?

I am passing -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5  for the Y axis.  Client wants all values to show as positive, but respecting the negative position  5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5 on the same Y axis.

Is there a way to step through axis labels and if the value is less than 1, multiply by -1, or just abs() all the ticks?






Evgenia
Telerik team
 answered on 18 Apr 2011
3 answers
59 views
In a hierarchical grid, how can I get the over effect in only master table but NOT in detail table?
The EnableRowHoverStyle gives me the effect both in master and detail table.
Iana Tsolova
Telerik team
 answered on 18 Apr 2011
2 answers
109 views
Hi,
Below code (_doPostBack) is working with explorer but not working with firefox.
Help please.

 <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
        <script language="javascript" type="text/javascript">
            function refreshParent() {
                 __doPostBack('<%=btnSave.UniqueID %>''');
            }
        </script>
 </telerik:RadScriptBlock>

Görkem
Top achievements
Rank 1
 answered on 18 Apr 2011
1 answer
40 views
Hi,
I'm creating a GroupBy expression dynamically based on user input:

RadGrid1.MasterTableView.GroupByExpressions.Add(txtUserInput.Text);

Occasionally the user gets this wrong which causes an error.
I simply want to catch this error in a try/catch block and handle it, but I'm not sure where to put the try/catch.
Any help would be appreciated.
Thanks,
Nick
Veli
Telerik team
 answered on 18 Apr 2011
1 answer
161 views

Hi.
I am migrating a former asp:grid, and since some features must remain the same (or as close to it as possible), the style of the GroupHeader should be similar to the former.
I need to find a way to change de color and size of the text of the GroupHeader:

<SelectFields>
    <telerik:GridGroupByField FieldAlias="My Group Description" FieldName="MyField"></telerik:GridGroupByField>
</SelectFields>

Is there any avaiable property to perform such a customization? And if there's none, can I do it by changing the CSS (even if it means creating a custom grid css file)?

Many thanks in advance.
Shinu
Top achievements
Rank 2
 answered on 18 Apr 2011
1 answer
78 views
is there a way to not highlight the text in a grid when the user selects or drags with their mouse in a grid?  I've attached a screen shot of what it is doing currently.  We have other grids on our site that don't allow this behavior but I cannot figure out how that is possible.

Thanks,

Jon
Sebastian
Telerik team
 answered on 18 Apr 2011
1 answer
131 views
Code is not downloading for sale dashboard demo in asp.net AJAX . Its throwing error like this
:

404 - File or directory not found.

The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.



please reply fast
Sebastian
Telerik team
 answered on 18 Apr 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Iron
Iron
Andrey
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Iron
Iron
Andrey
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?