Update in customized RadGrid

2 posts, 0 answers
  1. Sylvain
    Sylvain avatar
    3 posts
    Member since:
    Sep 2013

    Posted 08 Oct 2014 Link to this post

    Hi,
    I have a problem using an Update method on customized RadGrid... It seems easy but I don't undestrand where is my miss...


    Telerik dll versions used in the solution :
    Telerik.Web.UI.dll : 2013.3.1324.40 (last modified 2014/01/23)
    Telerik.Web.UI.Skins.dll : 2013.3.1324.40 (last modified 2014/01/23)


    Here is my Grid definition in projects.aspx file : 
    <telerik:RadGrid AutoGenerateColumns="false" OnNeedDataSource="RadGrid1_NeedDataSource" ID="RadGridProjets" AllowSorting="true"           
    AllowFilteringByColumn="True" runat="server"               
    AllowAutomaticInserts="false" AllowAutomaticUpdates="false" AllowAutomaticDeletes="false"  
    OnUpdateCommand="RadGridProjets_UpdateCommand"
    EnableLinqExpressions="false" AllowPaging="true" PageSize="30" AutoPostBackOnFilter="true">
                   
    <ExportSettings HideStructureColumns="true" IgnorePaging="true" SuppressColumnDataFormatStrings="false" FileName="Projets" ExportOnlyData="true">
                          <Excel Format="Html" FileExtension="XLS"></Excel>         
    </ExportSettings>

    <MasterTableView TableLayout="Auto" CommandItemDisplay="Top" EditMode="PopUp" CommandItemSettings-AddNewRecordText="Nouveau projet">
                              <PagerStyle Mode="NextPrevAndNumeric" PageSizes="10,30,50,100,500,1000" AlwaysVisible="true" Position="Bottom" />                           
                              <CommandItemSettings ShowExportToPdfButton="false" ShowAddNewRecordButton="true" ShowExportToExcelButton="true" refreshText="Rafraichir" ExportToExcelText="Exportation excel">
                              </CommandItemSettings>
                               <Columns>                                           
                                                <telerik:GridEditCommandColumn UniqueName="EditCol" />                                              
                                                <telerik:GridTemplateColumn UniqueName="Libelle_Projet" HeaderText="Libellé" DataField="Libelle_Projet" SortExpression="Libelle_Projet">                                                          
                                                                 <ItemTemplate><%# Eval("Libelle_Projet") %></ItemTemplate>
                                                  </telerik:GridTemplateColumn>                                              
                                                   <telerik:GridTemplateColumn UniqueName="Num_PRP" HeaderText="Num PRP" DataField="Num_PRP" sortExpression="Num_PRP">                                                    
                                                                  <ItemTemplate><%# Eval("Num_PRP") %></ItemTemplate>                                            
                                                     </telerik:GridTemplateColumn>               
                              </Columns>                         
                              <EditFormSettings EditFormType="Template">                                             
                                                    <FormTemplate>                                                              
                                                                   <table id="FormTemplateTable" cellspacing="1" cellpadding="1" width="100%" border="0" class="module">
                                                                                 <tr>                                                                                           
                                                                                             <td>Num PRP </td>
                                                                                              <td>
                                                                                                       <asp:TextBox ID="NumPRP" Text='<%# Bind("Num_PRP")%>' runat="server" TabIndex="9"></asp:TextBox>                                                                                                             
                                                                                                        <asp:RequiredFieldValidator ID="NumPRPRequiredFieldValidator" runat="server" CssClass="text-error" ControlToValidate="NumPRP" ErrorMessage="Veuillez entrer un Numéro de PRP">                                                                                                           
                                                                                                          </asp:RequiredFieldValidator>                                                                                           
                                                                                               </td>                                                                                            
                                                                                                <td>Libellé</td>                                                                                          
                                                                                                <td>                                                                                                           
                                                                                                            <asp:TextBox ID="LibelleProjet" Text='<%# Bind("Libelle_Projet") %>' runat="server" TabIndex="8">                                                                                                            
                                                                                                          </asp:TextBox>                                                                                                            
                                                                                                           <asp:RequiredFieldValidator ID="LibelleProjetRequiredFieldValidator" runat="server" CssClass="text-error" ControlToValidate="LibelleProjet" ErrorMessage="Veuillez entrer un libellé de projet">
                                                                                                           </asp:RequiredFieldValidator>                                                                          
                                                                                               </td>                                                                             
                                                                                </tr>                                                                                      
                                                            </table>                       
                                                            <table id="FormTemplateCommentaire" cellspacing="1" cellpadding="1" width="100%" border="0" class="module">                                                                                                        
                                                                                <tr>                                                                                             
                                                                                           <td align="right" colspan="2">  
                                                                                                               <asp:Button ID="btnUpdate" Text='<%# (Container is
    GridEditFormInsertItem) ? "insert" : "Update" %>' runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "Update" : "Update" %>'>                                                                                                        
                                                                                                       </asp:Button>&nbsp;                                                                                                                          
                                                                                                       <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False" CommandName="Cancel"></asp:Button>                                                                                            
                                                                                         </td>                                                                              
                                                                                </tr>
                                                                                 <tr>
                                                                                             <td>&nbsp;</td>                                                                                        
                                                                                             <td>&nbsp;</td>
                                                                               </tr>                                                              
                                                                </table>
                                                  </FormTemplate>             
                            </EditFormSettings>        
    </MasterTableView> 
    <ClientSettings>                       
    <ClientEvents OnPopUpShowing="OnPopUpShowing" />
                          <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="True" />        
                           <Resizing AllowColumnResize="True" AllowRowResize="false" ResizeGridOnColumnResize="false" ClipCellContentOnResize="false" EnableRealTimeResize="true" AllowResizeToFit="false" />            
    </ClientSettings>
    </telerik:RadGrid>



    Here is my Grid update function in projects.aspx.cs file :
    protected void RadGridProjets_UpdateCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)

            {         
                    this.InsertUpdate(sender, e);
            }
    protected void InsertUpdate(object sender, Telerik.Web.UI.GridCommandEventArgs e)
            {      
                    object editorValueId = null;           
                    GridEditableItem editedItem = e.Item as GridEditableItem;          
                    GridEditManager editMan = editedItem.EditManager;                                         
                   //code to manage project data
             }
    When i call EditManager I have the following error :
    Telerik.Web.UI.GridBindingException: {"The current EditFormType does not support the requested editing
    capabilities."}

    StackTrace :

       à Telerik.Web.UI.GridEditFormItem.get_EditManager()
       à Suivi_Activite.Projets.InsertUpdate(Object sender, GridCommandEventArgs e) dans d:\Projects\Suivi_Activite_DIM\Test1\Projets.aspx.cs:ligne 134
       à Suivi_Activite.Projets.RadGridProjets_UpdateCommand(Object sender, GridCommandEventArgs e) dans d:\Projects\Suivi_Activite_DIM\Test1 Projets.aspx.cs:ligne 123
       à Telerik.Web.UI.RadGrid.OnUpdateCommand(GridCommandEventArgs e)
       à Telerik.Web.UI.RadGrid.CallOnUpdateCommand(GridCommandEventArgs e)
       à Telerik.Web.UI.GridCommandEventArgs.ExecuteCommand(Object source)
       à Telerik.Web.UI.RadGrid.OnBubbleEvent(Object source, EventArgs e)
       à System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
       à Telerik.Web.UI.GridEditFormItem.OnBubbleEvent(Object source, EventArgs e)
       à System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
       à System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e)
       à System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)
       à System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
       à System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
       à System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
       à System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


    Do you have any ideas ?
    Thanks in advance
  2. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1793 posts

    Posted 13 Oct 2014 Link to this post

    Hello Sylvain,

    The error that you are receiving is due to the fact that you are using FormTemplate for your editing and the EditManager could not be used in such scenario, because there is no relationship between the grid columns and the controls within the FormTemplate. When FormTemplate is used, in order to get obtain certain values you will have to manually get reference to each control by using FindControl() from the edit item.

    Detailed information on this matter could be found in the following help article:
    Hope this helps.



    Regards,
    Konstantin Dikov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top