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

Error Editing Rad Grid

3 Answers 89 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tracy
Top achievements
Rank 1
Tracy asked on 27 Jun 2012, 01:27 AM
Hi,

I have a rad grid that I am putting into edit mode on row double click.  This functionality works great until I put and InsertItemTemplate on any of the fields.

When I put an InsertItemTemplate on any of the fields and then double click the row to put it into edit mode I get the following javascript error.

Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: Object reference not set to an instance of an object.

   _endPostBack: function PageRequestManager$_endPostBack(error, executor, data) {
        if (this._request === executor.get_webRequest()) {
            this._processingRequest = false;
            this._additionalInput = null;
            this._request = null;
        }

        var eventArgs = new Sys.WebForms.EndRequestEventArgs(error, data ? data.dataItems : {}, executor);
        Sys.Observer.raiseEvent(this, "endRequest", eventArgs);
        if (error && !eventArgs.get_errorHandled()) {
            throw error;
        }
    },



Below is a stripped down version of my grid.  Can you please take a look and tell me what I am doing wrong.
Thank you for you assistance.

Tracy
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="QBF PRJ Forecasting Bak1.aspx.vb" Inherits="IPS_Gateway.QBF_PRJ_Forecasting_Bak1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<head id="Head1" runat="server">
    <title></title>
</head>
     
    <script src="../../Scripts/ControlSelectOnFocus.js" type="text/javascript"></script>
    <script  type="text/javascript" >
 
    function RowDblClick(sender, eventArgs) {
        editedRow = eventArgs.get_itemIndexHierarchical();
        $find("<%= rgvMainGrid.ClientID %>").get_masterTableView().editItem(editedRow);
    }
    function CancelEdit(sender, args) {
        var c = confirm("Are you sure you want to cancel your changes>");
        if (c == true) {
            $find("<%= rgvMainGrid.ClientID %>").get_masterTableView().cancelAll();
        }
    }
    function GridCommand(sender, args) {
         
        if (args.get_commandName() != "Edit") {
            editedRow = null;
        }
        
    }
    </script>
    
 
<body>
    <form id="form1" runat="server">
 <act:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" EnablePartialRendering="true" AsyncPostBackTimeOut="600"/>
    <telerik:RadWindowManager ID="rwmManager" runat="server"></telerik:RadWindowManager
 
        <asp:SqlDataSource ID="SQLDS_ForecastedCostEntry"     runat="server"  ConnectionString="<%$ ConnectionStrings:IPSDataConnectionString %>" SelectCommandType="StoredProcedure" SelectCommand="[Project].[DSP_ForecastedHoursEntry-Sel]" />
        <asp:SqlDataSource ID="SQLDS_ForecastedCostUpdate"    runat="server"  ConnectionString="<%$ ConnectionStrings:IPSDataConnectionString %>" SelectCommandType="StoredProcedure" SelectCommand="[Project].[DSP_ForecastedHoursEntry-Ins-Upd]" />
 
    <asp:panel ID="pnlPage"   runat="server"  cssClass="css_GPC01_Panel_MainContent">     
    <wuc:PageHeader id="wucPageHeader" runat="server"></wuc:PageHeader>           
            <asp:Panel ID="pnlPageContent"         runat="server"     cssClass="css_GPC01_Panel_PageContent" >
     
<telerik:RadAjaxPanel ID="rapMainGrid" runat="server">
 
                    <telerik:RadGrid ID="rgvMainGrid"          runat="server"  DataSourceID="SQLDS_ForecastedCostEntry"
                                         EnableEmbeddedSkins="true"         Skin="Office2010Silver"            Height="400px"  Width="1230px"
                                         EnableViewState="true"             AutoGenerateColumns="false"     AllowMultiRowSelection="false"     
                                         AllowAutomaticDeletes="false"      AllowAutomaticInserts="true"    AllowAutomaticUpdates="true"        EnableLinqExpressions="false"                                                                       
                                         EnableHeaderContextMenu="true"     
                                         AllowFilteringByColumn="false"    
                                                     AllowPaging="true"                  PageSize="1000">                                 
                             
                            <HeaderStyle Font-Bold="true" HorizontalAlign ="Center"  VerticalAlign="Middle" Wrap="false" font-size="10px"/>
                            <ItemStyle HorizontalAlign="Right" />
                            <AlternatingItemStyle HorizontalAlign="Right" />
                            <HeaderStyle HorizontalAlign="Center"  Width="40px"/>
                            <PagerStyle AlwaysVisible="true"    Mode="NextPrevNumericAndAdvanced"/>
                            <FooterStyle HorizontalAlign="Right" />
                            <ClientSettings AllowColumnsReorder="true"   AllowDragToGroup="false"  AllowColumnHide="false" ReorderColumnsOnClient="true" EnablePostBackOnRowClick="false"  AllowExpandCollapse="true"
                            EnableRowHoverStyle  = "true" >
                             
                                <ClientEvents   OnCommand="GridCommand" OnRowDblClick="RowDblClick" />
                                <Selecting  AllowRowSelect="true" />                               
                                <Resizing   AllowColumnResize="True"    AllowRowResize="False"          ResizeGridOnColumnResize="false" EnableRealTimeResize="True"      ></Resizing>                                     
                                <Scrolling  AllowScroll="True"          UseStaticHeaders="True"         SaveScrollPosition="true"       FrozenColumnsCount="4" />
                            </ClientSettings>
                            <MasterTableView    DataSourceID="SQLDS_ForecastedCostEntry"           Name="MasterGrid"
                                                EnableViewState="true"                   ShowFooter="true"  ShowGroupFooter="true" ShowHeadersWhenNoRecords="true"                             
                                                EditMode="InPlace"                      CommandItemDisplay="Top"   TableLayout="Fixed">                                                               
                            <CommandItemTemplate>
                                <asp:Table ID="tblCommandTemplate" runat="server" Width="1230px" CellSpacing="0" CellPadding="0">
                                    <asp:TableRow ID="trowCommandTemplate1" Height="25px" runat="server" style="display:block;"  >
                                        <asp:TableCell >
                                            <telerik:RadButton ID="rbtAdd"             runat="server" CommandName="InitInsert"       Skin="Transparent" Text="Add"              Icon-PrimaryIconURL="<%$ Resources:Images,AddRecord16%>"    style="position:absolute;left:10px;font-size:12px;"  ToolTip="Add New Record"       />  
                                            <telerik:RadButton ID="rbtCancel"          runat="server"  OnClientClicked="CancelEdit"        Skin="Transparent" Text="Cancel"           Icon-PrimaryIconURL="<%$ Resources:Images,CancelRecord16%>" style="position:absolute;left:10px;font-size:12px;"  ToolTip="Cancel Add/Edit"    Visible='<%# rgvMainGrid.EditIndexes.Count > 0 Or rgvMainGrid.MasterTableView.IsItemInserted %>'    AutoPostBack="false" />  
                                            <telerik:RadButton ID="rbtSaveNew"         runat="server" CommandName="PerformInsert"    Skin="Transparent" Text="Save"             Icon-PrimaryIconURL="<%$ Resources:Images,SaveRecord16%>"   style="position:absolute;left:80px;font-size:12px;"  ToolTip="Save New Record"    Visible='<%# rgvMainGrid.MasterTableView.IsItemInserted%>'                                           />   
                                            <telerik:RadButton ID="rbtSave"            runat="server" CommandName="UpdateEdited"      Skin="Transparent" Text="Save"             Icon-PrimaryIconURL="<%$ Resources:Images,SaveRecord16%>"   style="position:absolute;left:80px;font-size:12px;"  ToolTip="Save Edited Record" Visible='<%# rgvMainGrid.EditIndexes.Count > 0 AND Not rgvMainGrid.MasterTableView.IsItemInserted%>'/>  
                                            </asp:TableCell>
                                        </asp:TableRow>
                                </asp:Table>
                            </CommandItemTemplate>
                                    <Columns>  
                                        <telerik:GridBoundColumn    DataField="Job"                              UniqueName="Job"                            HeaderText="Job" />                       
                                        <telerik:GridBoundColumn    UniqueName="Extra"        DataField="Extra"      Display="true" />                        
  
                                        <telerik:GridBoundColumn    DataField="CostCode"                        UniqueName="CostCode"                       HeaderText="Cost Code"                                                 HeaderStyle-Width="70px"   ItemStyle-HorizontalAlign="Left"   ReadOnly="true" />                                   
 
                                        <telerik:GridTemplateColumn     UniqueName="EmployeeName"   HeaderText="EmployeeName"  DataField="EmployeeName"  HeaderStyle-Width="150px"   >
                                           <ItemTemplate>
                                                <asp:Label ID="lblEmployeeName" runat="server" Text='<%# Bind("EmployeeName") %>' />
                                            </ItemTemplate>
                                            <InsertItemTemplate>
                                                <asp:TextBox ID="txtTest" runat="server"   />
                                            </InsertItemTemplate>
                                             
                                        </telerik:GridTemplateColumn>
                                </Columns>                               
                            </MasterTableView>
                        </telerik:RadGrid>
</telerik:RadAjaxPanel>
            <telerik:GridNumericColumnEditor ID="HrsEditor" runat="server"  >
               
        </telerik:GridNumericColumnEditor>
            </asp:Panel>
      
 
    </asp:panel>
    </form>
</body>
</html>

3 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 27 Jun 2012, 05:05 AM
Hi Tracy,

I could able to solve this issue by using EditItemTemplate.

ASPX:
<telerik:GridTemplateColumn UniqueName="EmployeeName" HeaderText="EmployeeName" DataField="LastName"
                                    HeaderStyle-Width="150px">
           <ItemTemplate>
                <asp:Label ID="lblEmployeeName" runat="server" Text='<%# Bind("LastName") %>' />
           </ItemTemplate>
           <EditItemTemplate>
               <asp:TextBox ID="txtTest" runat="server" Text="Shinu" />
           </EditItemTemplate>
          <InsertItemTemplate>
                <asp:TextBox ID="txtTestInsert" runat="server" />
         </InsertItemTemplate>
 </telerik:GridTemplateColumn>

Thanks,
Shinu.
0
Tracy
Top achievements
Rank 1
answered on 27 Jun 2012, 01:43 PM
Hi Shinu,

Thank you for your response.  That worked for me.  I thought that if there wasn't an edit template defined it would just use the item template.  Is the rule if you have an insert template you also have to have an edit template?

Tracy
0
Shinu
Top achievements
Rank 2
answered on 02 Jul 2012, 10:07 AM
Hi Tracy,

EditItemTemplate will work for both Edit and Insert. But ItemTemplate won't work for Edit/insert.You got the error because you are editing the RadGrid on double click of the row and you have only set the InsertItemTemplate which only works for insertion not for edit.ItemTemplate is only for view mode.

Thanks,
Shinu.
Tags
Grid
Asked by
Tracy
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Tracy
Top achievements
Rank 1
Share this question
or