Telerik Forums
UI for ASP.NET AJAX Forum
6 answers
366 views
Hi guys,


We are using Telerik  ASP.NET Ajax Controls for some time without embedded resources by setting the appropriate configuration settings:


<add key="Telerik.EnableEmbeddedSkins" value="false"/>

<add key="Telerik.EnableEmbeddedBaseStylesheet" value="false"/>

<add key="Telerik.EnableEmbeddedScripts" value="false"/>        

 

We have only one JavaScript file, Telerik.js , that contains all java script files for all controls and one .css file, Common.css,  that contains all common styles for all controls. For each skin, we create a single css file with all  controls styles for that skin.

Our problem is when we update the Telerik framework, because we have to regenerate the files mentioned above. It seems that although we are following
the order specified in the documentation bellow,

http://www.telerik.com/help/aspnet-ajax/introduction-disabling-embedded-resources.html

when merging the java script files, we end up with Java Script errors.

We are looking for some help regarding the merging procedure or eventually a tool that, for instance, we’ll let us select the controls we want to use and will generate a single .js file  with all the scripts, and single .css file with all common styles.
 

Best regards,
Dan Ciobanu
Christian
Top achievements
Rank 1
 answered on 23 Jan 2015
2 answers
188 views
Hi !
I have a radmenu in my masterpage that updates the content of the "mainarea"  with is an iFrame wrapped in a updatepanel.

If I  use a radgrid and try to delete a item the confirmwindow is always displayed centered regarding to my iFrame.
This is not very nice since the user cannot se the confimwindow if trying to delete an item far up or far down in the grid.
I' thinking the user shouldn't have to scroll to find the window.

If I use ConfirmDialogType="Classic" it works nice and the window is showing besides the selected row.
If I use ConfirmDialogType="Radwindow"  outside the iFrame it also works nice .

I would like the window to show up besides the area where I clicked or  centred in relation to the screen.

Anyone nows how to solve this issue ?

Regards
Stefan
Stefan
Top achievements
Rank 1
 answered on 23 Jan 2015
1 answer
113 views
<telerik:RadGrid ID="grdLogframe" OnNeedDataSource="grdLogframe_NeedDataSource" <br>                    OnItemDataBound="grdLogframe_ItemDataBound" OnPreRender="grdLogframe_PreRender" runat="server" AutoGenerateColumns="false"><br>                    <MasterTableView DataKeyNames="NodeID" Name="tblLogframe"><br>                        <Columns><br>                            <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn"></telerik:GridEditCommandColumn><br>                            <telerik:GridBoundColumn UniqueName="NodeID" DataField="NodeID" Visible="false"></telerik:GridBoundColumn><br>                            <telerik:GridTemplateColumn UniqueName="NodeText" DataField="NodeText" HeaderText="Objectives"><br>                                <ItemTemplate><br>                                    <%# Eval("ProjectLogframeNodeType.NodeTypeName") %>&nbsp;:&nbsp;<%# Eval("NodeText") %><br>                                </ItemTemplate><br>                            </telerik:GridTemplateColumn><br>                            <telerik:GridTemplateColumn UniqueName="indicators"><br>                                <itemtemplate><br>                                       <telerik:RadGrid ID="grdIndicators" runat="server" AutoGenerateColumns="false" ShowHeader="true" OnPreRender="grdIndicators_PreRender" OnItemCreated="grdIndicators_ItemCreated" OnItemDataBound="grdIndicators_ItemDataBound"><br>                                           <MasterTableView DataKeyNames="ProjectLogframeIndicatorID" <br>                                               NoMasterRecordsText ="Indicators not defined yet" Name="tblIndicators"><br>                                               <Columns><br>                                                   <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn"></telerik:GridEditCommandColumn><br>                                                   <telerik:GridBoundColumn HeaderText="Project Indicators" UniqueName="Description" DataField="Description"></telerik:GridBoundColumn><br>                                                   <telerik:GridBoundColumn HeaderText="Corporate Indicators" UniqueName="CorpResultFrameworkIndicatorID" DataField="CorpResultFrameworkIndicatorID"></telerik:GridBoundColumn><br>                                                   <telerik:GridBoundColumn HeaderText="Programme Indicators" UniqueName="ProgrameIndicatorID" DataField="ProgrameIndicatorID"></telerik:GridBoundColumn><br>                                                   <telerik:GridBoundColumn HeaderText="Baseline" UniqueName="Baseline" DataField="Baseline"></telerik:GridBoundColumn><br>                                                   <telerik:GridBoundColumn HeaderText="Targets" UniqueName="Targets" DataField="Targets"></telerik:GridBoundColumn><br>                                                   <telerik:GridBoundColumn HeaderText="Means of Verifications" UniqueName="MeansOfVerification" DataField="MeansOfVerification"></telerik:GridBoundColumn><br>                                               </Columns><br>                                               <CommandItemSettings AddNewRecordText="Add Indicator" AddNewRecordImageUrl="../Img/insert.png" /><br>                                           </MasterTableView><br>                                       </telerik:RadGrid><br>                                </itemtemplate><br>                            </telerik:GridTemplateColumn>
...

I am doing the nested grid binding inside the item created of the outer grid.
the issue is with the CRUD operations on the inner grids, whenever they post back the whole grid structure is recreated and the post back event is lost.
This is manifested specifically with the InitInsert and InitUpdate commands on inner grids. the grid refreshes but the action is lost.

how can i perform this?

thank you
Angel Petrov
Telerik team
 answered on 23 Jan 2015
1 answer
82 views
I would like to open a popup window and then access a client side function within that window at a later time in the session. Is there any way to do this? How do I get a reference to that popup window?

I know how to call a parent window from a child but not the other way around,

Thanks...
Marin Bratanov
Telerik team
 answered on 23 Jan 2015
4 answers
280 views
I don't know why I have such a hard time grasping the fundamentals of radgrid when in edit/insert mode but I sure do. I do not see how to edit/trap the values I am editing. I am trying to work with a checkbox list that has the days of week in a gridtemplatecolum. I am using editForms mode as per tutorials. I can using the insert_command get the selected values and convert those to a string for sql_insert to a column, however I can't get the value out when in edit mode back into the list. ie. convert Monday,Tuesday into the checkbox list as I can't find the checkboxlist. I am using EditCommand. once i can find the control, reading it back in should not be a problem... its a matter of finding it.

Dim appid As String  
    Dim cblstr As String  
 
      
    Protected Sub SqlDataSource1_Inserting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles SqlDataSource1.Inserting  
        e.Command.Parameters("@AppID").Value = Applicants1.appid  
        e.Command.Parameters("@NotAvailalble").Value = cblstr 
    End Sub  
 
 
    Protected Sub SqlDataSource1_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Handles SqlDataSource1.Selecting  
        If Applicants1.appid IsNot Nothing Then  
            appid = Applicants1.appid  
            e.Command.Parameters("@AppID").Value = appid 
        End If  
 
    End Sub  
 
    Protected Sub RadGrid1_EditCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.EditCommand  
        If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then  
            Dim cbl As CheckBoxList = (TryCast(e.Item, GridEditableItem)).Controls(0).FindControl("CBNotAvail")  
            ' this totally fails as it says it can't find the item  
        End If  
    End Sub  
 
    Protected Sub RadGrid1_InsertCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.InsertCommand  
          
        If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then  
            Dim cbl As CheckBoxList = (TryCast(e.Item, GridEditableItem)).Controls(0).FindControl("CBNotAvail")  
            cblstr = functions.CBListValues(cbl)  
        End If  
 
 
    End Sub 


Source
        <telerik:GridTemplateColumn UniqueName="NotAvailable" HeaderText="Not Available" Visible="False">  
                     <EditItemTemplate> 
                    <asp:CheckBoxList ID="CBNotAvail" runat="server" SelectedValue='<%# Bind("NotAvailalble") %>' > 
                    <asp:ListItem>Monday</asp:ListItem> 
                    <asp:ListItem>Tuesday</asp:ListItem> 
                                            </asp:CheckBoxList> 
                    </EditItemTemplate> 
                    </telerik:GridTemplateColumn> 
Kostadin
Telerik team
 answered on 23 Jan 2015
1 answer
282 views
So I am trying to use a radgrid to allow updates to my database, and while the page functions properly, I can't seem to save the data back to the database, any help you can offer would be appreciated greatly. I am new to both C# and asp.

Page Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ValidationEdit.aspx.cs" Inherits="EditPages_ValidationEdit" MasterPageFile="~/EUEMain.master"   %>
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
 
 
<asp:Content ID="Content1" ContentPlaceHolderID="cphLeftNav" runat="Server">
    <asp:HyperLink ID="HomeLink" runat="server" NavigateUrl="..\Default.aspx" Text="Home" />
    <br />
    <asp:HyperLink ID="AddLink" runat="server" Text="Status Edit Page" />
    <br />
</asp:Content>
 
<asp:Content ID="Content2" ContentPlaceHolderID="cphContent" runat="Server">
    <p></p>
<p></p>
<p></p>
    <h1>Subdivision Statuses</h1>
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
</telerik:RadScriptManager>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
  <AjaxSettings>
    <telerik:AjaxSetting AjaxControlID="RadGrid1">
      <UpdatedControls>
        <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
      </UpdatedControls>
    </telerik:AjaxSetting>
  </AjaxSettings>
</telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" />
    <telerik:RadGrid ID="RadGrid1" runat="server" DataModelID="Status" AllowPaging="True" AllowAutomaticUpdates="True" AllowAutomaticInserts="True"
        AllowAutomaticDeletes="true" AllowSorting="true" OnItemCreated="RadGrid1_ItemCreated"
        OnItemInserted="RadGrid1_ItemInserted" OnPreRender="RadGrid1_PreRender" OnInsertCommand="RadGrid1_InsertCommand" OnNeedDataSource="Radgrid1_NeedDataSource">
         
    <PagerStyle Mode="NextPrevAndNumeric" />
        <MasterTableView  AutoGenerateColumns="False"
            DataKeyNames="Description" CommandItemDisplay="Top">
            <Columns>
                <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
                </telerik:GridEditCommandColumn>
                <telerik:GridBoundColumn DataField="Description" HeaderText="Description" SortExpression="Description"
                    UniqueName="Description" >
                </telerik:GridBoundColumn>
                <telerik:GridCheckBoxColumn  DataField="Visible" HeaderText="Visible" SortExpression="Visible"
                    UniqueName="Visible">
                </telerik:GridCheckBoxColumn>
                <telerik:GridBoundColumn DataField="StatusType" HeaderText="Status Type" UniqueName="StatusType"></telerik:GridBoundColumn>
                <telerik:GridButtonColumn Text="Delete" CommandName="Delete" ButtonType="ImageButton" />
            </Columns>
            <EditFormSettings>
                <EditColumn ButtonType="ImageButton" />
            </EditFormSettings>
        </MasterTableView>
 
    </telerik:RadGrid>
    <h1>
        Track Statuses
        <telerik:RadGrid ID="RadGrid2" runat="server" DataModelID="Status" AllowPaging="True" AllowAutomaticUpdates="True" AllowAutomaticInserts="True"
        AllowAutomaticDeletes="true" AllowSorting="true" OnItemCreated="RadGrid1_ItemCreated"
        OnItemInserted="RadGrid1_ItemInserted" OnPreRender="RadGrid1_PreRender" OnInsertCommand="RadGrid1_InsertCommand" OnNeedDataSource="Radgrid1_NeedDataSource">
         
    <PagerStyle Mode="NextPrevAndNumeric" />
        <MasterTableView  AutoGenerateColumns="False"
            DataKeyNames="Description" CommandItemDisplay="Top">
            <Columns>
                <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
                </telerik:GridEditCommandColumn>
                <telerik:GridBoundColumn DataField="Description" HeaderText="Description" SortExpression="Description"
                    UniqueName="Description" >
                </telerik:GridBoundColumn>
                <telerik:GridCheckBoxColumn DataField="Visible" HeaderText="Visible" SortExpression="Visible"
                    UniqueName="Visible">
                </telerik:GridCheckBoxColumn>
                <telerik:GridBoundColumn DataField="StatusType" HeaderText="Status Type" UniqueName="StatusType"></telerik:GridBoundColumn>
                 
                <telerik:GridButtonColumn Text="Delete" CommandName="Delete" ButtonType="ImageButton" />
            </Columns>
            <EditFormSettings>
                <EditColumn ButtonType="ImageButton" />
            </EditFormSettings>
        </MasterTableView>
 
    </telerik:RadGrid>
    </h1>
     <asp:EntityDataSource ID="EntityDataSourceStatus" runat="server" ConnectionString="name=PtcDbModelEntities"
        DefaultContainerName="PtcDbModelEntities" EntitySetName="Status" OrderBy="it.[ContactName]"
        EntityTypeFilter="Description" EnableDelete="True" EnableFlattening="False" EnableInsert="True" EnableUpdate="True">
    </asp:EntityDataSource>
</asp:Content>

and the Code behind:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web.UI;
using Model;
using Telerik.Web.UI;
 
public partial class EditPages_ValidationEdit : BNSF.EUECommonApplication.EUEBasePage
{
 
    public List<Status> StatusList { get; set; }
    public object CurrentSubStatusList { get; set; }
 
    protected void Page_Load(object sender, EventArgs e)
    {
         
        AddLink.NavigateUrl = @"..\EditPages\ValidationEdit";
        if (!Page.IsPostBack)
        {
             
                using (PtcDbModel localDb = new PtcDbModel())
                {
                    var localTemp = (from tempList in localDb.Status
                                     where tempList.StatusType == "S"
                                     select tempList)
                                    .ToList();
                    var localTemp2 = (from tempList in localDb.Status
                                      where tempList.StatusType == "T"
                                      select tempList)
                                    .ToList();
                    CurrentSubStatusList = localTemp;
                    CurrentTrackStatusList = localTemp2;
 
                    var tempDetailList = CurrentSubStatusList;
                    var tempDetailList2 = CurrentTrackStatusList;
                    RadGrid1.DataSource = tempDetailList;
                    RadGrid2.DataSource = tempDetailList2;
                }
            }
        }
 
    public List<Status> CurrentTrackStatusList { get; set; }
 
 
    protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
    {
        if (e.Item is GridEditableItem && e.Item.IsInEditMode)
        {
            if (!(e.Item is GridEditFormInsertItem))
            {
                GridEditableItem item = e.Item as GridEditableItem;
                GridEditManager manager = item.EditManager;
                GridTextBoxColumnEditor editor = manager.GetColumnEditor("Description") as GridTextBoxColumnEditor;
                editor.TextBoxControl.Enabled = true;
            }
        }
    }
    protected void RadGrid1_ItemInserted(object source, GridInsertedEventArgs e)
    {
        if (e.Exception != null)
        {
 
            e.ExceptionHandled = true;
            SetMessage("Customer cannot be inserted. Reason: " + e.Exception.Message);
 
        }
        else
        {
            SetMessage("New customer is inserted!");
        }
    }
    private void DisplayMessage(string text)
    {
        RadGrid1.Controls.Add(new LiteralControl(string.Format("<span style='color:red'>{0}</span>", text)));
    }
 
    private void SetMessage(string message)
    {
        gridMessage = message;
    }
 
    private string gridMessage = null;
 
    protected void RadGrid1_PreRender(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(gridMessage))
        {
            DisplayMessage(gridMessage);
            RadGrid1.DataBind();
            RadGrid2.DataBind();
        }
    }
 
    protected void RadGrid1_InsertCommand(object sender, GridCommandEventArgs e)
    {
        if (e.Item is GridEditableItem)
        {
            GridEditableItem editedItem = e.Item as GridEditableItem;
            //here editedItem.SavedOldValues will be the dictionary which holds the
            //predefined values
 
            //Prepare new dictionary object
            Hashtable newValues = new Hashtable();
            e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem);
            //the newValues instance is the new collection of key -> value pairs
            //with the updated ny the user data
        }
    }
 
 
    protected void Radgrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        using (PtcDbModel localDb = new PtcDbModel())
        {
            var localTemp = (from tempList in localDb.Status
                             where tempList.StatusType == "S"
                             select tempList)
                            .ToList();
            
 
            var localTemp2 = (from tempList in localDb.Status
                              where tempList.StatusType == "T"
                              select tempList)
                                     .ToList();
            CurrentSubStatusList = localTemp;
            CurrentTrackStatusList = localTemp2;
 
            var tempDetailList = CurrentSubStatusList;
            var tempDetailList2 = CurrentTrackStatusList;
            RadGrid1.DataSource = tempDetailList;
            RadGrid2.DataSource = tempDetailList2;
 
        }
    }
}
Konstantin Dikov
Telerik team
 answered on 23 Jan 2015
1 answer
149 views
I have a grid as follows. EditMode=Batch, AllowMultiRowSelection, AllowMultiRowEdit = true

<telerik:RadGrid ID="RadGrid1" runat="server" ClientSettings-Selecting-AllowRowSelect="true" AutoGenerateColumns="False" AllowMultiRowSelection="true" OnNeedDataSource="RadGrid1_NeedDataSource" AllowMultiRowEdit="true">
       <MasterTableView EditMode="Batch" DataKeyNames="Discipline_ID" CommandItemDisplay="Top">
           <BatchEditingSettings EditType="Row" OpenEditingEvent="DblClick" />
           <CommandItemTemplate>
               <asp:ImageButton ID="Button_Save" runat="server" ToolTip="Save" ImageUrl="~/dhtmlx/imgs/save.png" Height="20" Width="20" style="padding:5px 0 0 5px;" OnClick="Button_Save_Click" />   
           </CommandItemTemplate>
           <Columns>
               <telerik:GridBoundColumn DataField="Discipline_ID" Display="false" UniqueName="Discipline_ID"></telerik:GridBoundColumn>
               <telerik:GridClientSelectColumn UniqueName="SelectCheckBox" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="50px"></telerik:GridClientSelectColumn>
               <telerik:GridBoundColumn DataField="Name" HeaderText="Name" UniqueName="Name" AllowSorting="true"></telerik:GridBoundColumn>
               <telerik:GridBoundColumn DataField="Description" HeaderText="Description" UniqueName="Description" AllowSorting="true"></telerik:GridBoundColumn>
           </Columns>
       </MasterTableView>
   </telerik:RadGrid>


When I click the save button in the CommandItemTemplate it fires this event:

protected void Button_Save_Click(object sender, ImageClickEventArgs e)
    {
        foreach (GridDataItem item in RadGrid1.EditItems)
        {
            Hashtable newValues = new Hashtable();
            item.OwnerTableView.ExtractValuesFromItem(newValues, item);
        }
    }


When I try to update the items that have been edited in the grid the RadGrid1.EditItems.Count is always 0.

Why aren't the items that I have edited marked as edited when I try to save them?

Thanks





















Konstantin Dikov
Telerik team
 answered on 23 Jan 2015
2 answers
156 views
I have a number of forms and grids that use RadAjaxManager to setup AJAX settings. This works well after the first click. That first clicks always does a full page refresh which is slow and does not show the RadAjaxLoadingPanel graphic. Is there a way to force the page to register the controls correctly so any click is handled correctly by RadAjaxManager?

The controls are placed in web parts that appear in SharePoint pages.
Bill Wolff
Top achievements
Rank 1
 answered on 22 Jan 2015
1 answer
112 views
I have a client side data bind on my RadGrid. The Delete and Update Commands work perfectly, but when I try to insert a new row my code breaks at the Checkbox bind with the following: "Specified cast is not valid." I am new to C#, Asp, and Telerik controls, any help would be greatly appreciated.
Here is my Page Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ValidationEdit.aspx.cs" Inherits="EditPages_ValidationEdit" MasterPageFile="~/EUEMain.master" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
 
<asp:Content ID="Content1" ContentPlaceHolderID="cphLeftNav" runat="Server">
    <asp:HyperLink ID="HomeLink" runat="server" NavigateUrl="..\Default.aspx" Text="Home" />
    <br />
    <asp:HyperLink ID="AddLink" runat="server" Text="Status Edit Page" />
    <br />
</asp:Content>
 
<asp:Content ID="Content2" ContentPlaceHolderID="cphContent" runat="Server">
 
    <h1>Subdivision Statuses</h1>
 
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server" />
    <asp:Label ID="Label1" runat="server" EnableViewState="False" Font-Bold="True" ForeColor="#FF8080">
    </asp:Label>
    <asp:Label ID="Label2" runat="server" EnableViewState="False" Font-Bold="True" ForeColor="#00C000">
    </asp:Label>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
 
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" />
 
    <div id="Testing">
        <telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSourceSub" AllowPaging="True" AllowAutomaticUpdates="True" AllowAutomaticInserts="True"
            AllowAutomaticDeletes="true" AllowSorting="true" AutoGenerateColumns="False" OnItemUpdated="RadGrid1_ItemUpdated"
            OnPreRender="RadGrid1_PreRender" OnItemInserted="RadGrid1_ItemInserted">
            <MasterTableView AutoGenerateColumns="False" CommandItemDisplay="TopAndBottom" DataKeyNames="StatusId" DataSourceID="SqlDataSourceSub">
                <Columns>
                    <telerik:GridEditCommandColumn>
                    </telerik:GridEditCommandColumn>
                    <telerik:GridBoundColumn DataField="StatusID" HeaderText="Status ID" UniqueName="StatusID" Visible="False" />
                    <telerik:GridBoundColumn DataField="StatusType" HeaderText="Status Type" UniqueName="StatusType" Visible="False" />
                    <telerik:GridBoundColumn DataField="Description" HeaderText="Description" UniqueName="Description" />
                    <telerik:GridCheckBoxColumn DataField="Visible" HeaderText="Visible" UniqueName="Visible" />
                    <telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="column" />
                </Columns>
                <EditFormSettings EditFormType="Template">
                    <FormTemplate>
                        <table id="table1">
                            <tr>
                                <td>Subdivision Status Details</td>
                            </tr>
                            <tr>
                                <td>
                                    <table id="Table2">
                                        <tr>
                                            <td >Status ID</td>
                                            <td>
                                                <asp:Label runat="server" ID="StatusIdLabel" Text='<%#Bind("StatusId") %>' Visible="False"></asp:Label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>Status Type</td>
                                            <td>
                                                <asp:TextBox runat="server" ID="StatusTypeTextBox" Text='<%#Bind("StatusType") %>'></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td runat="server">Description</td>
                                            <td>
                                                <asp:TextBox runat="server" ID="DescriptionTextBox" Text='<%#Bind("Description") %>'></asp:TextBox>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>Visible</td>
                                            <td>
                                                <asp:CheckBox  Checked='<%#Bind("Visible") %>' ID="VisibleCheckBox" runat="server" />
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                                <asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                                                    runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'></asp:Button
                                    <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
                                        CommandName="Cancel"></asp:Button>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                        </table>
                    </FormTemplate>
                </EditFormSettings>
            </MasterTableView>
        </telerik:RadGrid>
    </div>
 
    <asp:SqlDataSource ID="SqlDataSourceSub" runat="server" ConnectionString="<%$ ConnectionStrings:PtcDbModelEntities %>"
        DeleteCommand="DELETE FROM [dbo].[Status] WHERE [StatusId] = @StatusId"
        InsertCommand="INSERT INTO [dbo].[Status] ([StatusType], [Description], [Visible], VALUES (@StatusType, @Description, @BitVisible)"
        SelectCommand="SELECT [StatusId], [StatusType], [Visible], [Description] FROM [dbo].[Status] where StatusType = 'S'"
        UpdateCommand="UPDATE [dbo].[Status] SET [StatusType] = @StatusType, [Description] = @Description,  Visible = @Visible  WHERE [StatusId] = @StatusId">
        <DeleteParameters>
            <asp:Parameter Name="StatusId" Type="Int32"></asp:Parameter>
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="StatusType" Type="String"></asp:Parameter>
            <asp:Parameter Name="Description" Type="String"></asp:Parameter>
            <asp:Parameter Name="Visible" Type="Boolean"></asp:Parameter>
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="StatusType" Type="String"></asp:Parameter>
            <asp:Parameter Name="Description" Type="String"></asp:Parameter>
            <asp:Parameter Name="Visible" Type="Boolean"></asp:Parameter>
            <asp:Parameter Name="StatusId" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
and my code Behind (C#):
using System;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
 
public partial class EditPages_ValidationEdit : BNSF.EUECommonApplication.EUEBasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        AddLink.NavigateUrl = @"..\EditPages\ValidationEdit.aspx";
    }
    protected void RadGrid1_ItemUpdated(object source, Telerik.Web.UI.GridUpdatedEventArgs e)
    {
        SqlDataSourceSub.UpdateParameters["Description"].DefaultValue = e.ToString();
        SqlDataSourceSub.UpdateParameters["StatusType"].DefaultValue = e.ToString();
        SqlDataSourceSub.UpdateParameters["Visible"].DefaultValue = e.ToString();
 
        if (e.Exception != null)
        {
            e.KeepInEditMode = true;
            e.ExceptionHandled = true;
            DisplayMessage(true, "Status " + e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["StatusId"] + " cannot be updated. Reason: " + e.Exception.Message);
        }
        else
        {
            DisplayMessage(false, "Status " + e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["StatusId"] + " updated");
        }
    }
 
    protected void RadGrid1_ItemInserted(object source, GridInsertedEventArgs e)
    {
         
        SqlDataSourceSub.InsertParameters["StatusType"].DefaultValue = e.ToString();
        SqlDataSourceSub.InsertParameters["Description"].DefaultValue = e.ToString();
        SqlDataSourceSub.InsertParameters["Visible"].DefaultValue = e.ToString();
    }
 
    protected void RadGrid1_ItemDeleted(object source, GridDeletedEventArgs e)
    {
        if (e.Exception != null)
        {
            e.ExceptionHandled = true;
            DisplayMessage(true, "Status " + e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["StatusId"] + " cannot be deleted. Reason: " + e.Exception.Message);
        }
        else
        {
            DisplayMessage(false, "Status " + e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["StatusId"] + " deleted");
        }
    }
 
    private void DisplayMessage(bool isError, string text)
    {
        Label label = (isError) ? this.Label1 : this.Label2;
        label.Text = text;
    }
 
    protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
    {
        if (e.CommandName == RadGrid.InitInsertCommandName) //"Add new" button clicked
        {
            GridEditCommandColumn editColumn = (GridEditCommandColumn)RadGrid1.MasterTableView.GetColumn("EditCommandColumn");
            editColumn.Visible = false;
        }
        else if (e.CommandName == RadGrid.RebindGridCommandName && e.Item.OwnerTableView.IsItemInserted)
        {
            e.Canceled = true;
        }
        else
        {
            GridEditCommandColumn editColumn = (GridEditCommandColumn)RadGrid1.MasterTableView.GetColumn("EditCommandColumn");
            if (!editColumn.Visible)
                editColumn.Visible = true;
        }
    }
    protected void RadGrid1_PreRender(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            RadGrid1.EditIndexes.Add(0);
            RadGrid1.Rebind();
        }
    }
}

Matthew
Top achievements
Rank 1
 answered on 22 Jan 2015
5 answers
808 views
I am getting this error when a user clicks Export on the radGrid heading:

Specified argument was out of the range of valid values.
Parameter name: index

[ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: index]
System.Web.UI.ControlCollection.get_Item(Int32 index) +11120470
Telerik.Web.UI.GridGroupPanel.get_MainTable() +54
Telerik.Web.UI.GridGroupPanel.OnPreRender(EventArgs e) +56

Any ideas? This also happens for PDF and Word exports. The grid uses an ObjectDataSource with EnablePaging true and a SortParameterName. Other grid functions like sorting, filtering, paging, and grouping work as advertised. The exports are setup in the markup like this:

    <ExportSettings Excel-Format="Html" Word-Format="Html" FileName="Batch"
        IgnorePaging="true" HideStructureColumns="true" OpenInNewWindow="true" ExportOnlyData="true">
Bill Wolff
Top achievements
Rank 1
 answered on 22 Jan 2015
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?