Close when Edit / Insert is finished

7 posts, 0 answers
  1. Brian Roy
    Brian Roy avatar
    4 posts
    Member since:
    Oct 2007

    Posted 22 Sep 2009 Link to this post

      No matter what i try i cant get the edit/insert form to close when i use forms or popup.


    //this throws and error : Insert item is available only when grid is in insert mode.
    protected void RadGrid1_InsertCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) {   
    e.Item.OwnerTableView.IsItemInserted = false;   
    //this had no effect   
    protected void RadGrid1_InsertCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) {   
    e.Cancelled = true;  
    // nothing on edit either   
    protected void RadGrid1_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgse) {   

    // some additional background info:

    I have tried it in forms & popup and with a user control and not




    <telerik:RadGrid ID="RadGrid1" runat="server"   
    <PagerStyle Mode="NextPrevAndNumeric" />   
    <MasterTableView Width="950" CommandItemDisplay="TopAndBottom" DataKeyNames="PromoCode" EditMode="EditForms" >   
    <asp:ImageButton ID="Button1" runat="server" ImageUrl="~/App_Themes/Default/Images/EditButton.gif"   
    Text="Edit" CommandName="Edit" />   
    <telerik:GridTemplateColumn HeaderText="PromoCode" SortExpression="PromoCode" UniqueName="PromoCode">  
    <asp:Label runat="server" ID="lblPromoCode" Text='<%# Eval("PromoCode") %>'></asp:Label>   
    <asp:TextBox runat="server" ID="tbxPromoCode" EnableViewState="true" ></asp:TextBox>   
    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="tbxPromoCode"   
    ErrorMessage="*" runat="server">   
    <telerik:GridButtonColumn ConfirmText="Delete this Item?" ConfirmDialogType="RadWindow"   
    ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"   


     Page.Response.Redirect does work but it is not an option. lol


  2. Todd Anglin
    Todd Anglin avatar
    2040 posts
    Member since:
    Aug 2005

    Posted 22 Sep 2009 Link to this post

    Hello Brian-

    Sorry to hear you're having trouble with the edit modes! Let's see if we can solve this problem.

    By default, when you edit a row with RadGrid using PopUp or Forms (or even UserControl), the edit form should automatically close when you fire the Insert/Update command. For some "proof by example," check out these live demos:

    That said, based on the RadGrid configuration you posted, it does not seem to be properly configured for data editing. I suggest you add a GridEditCommandColumn. This column will automatically provide the "Edit" button in the "read mode" and the "Update/Cancel" buttons in the edit mode. An example with this column can be found here:

    Additionally, make sure your Page Validation is not causing problems with your data operations. I see that you've got some ASP.NET validation controls in your edit templates. If those do not validate, your grid will appear not to "exit" edit mode when the page is posted.

    Give that a try and let me know if it helps.

  3. Echarbeneau
    Echarbeneau avatar
    21 posts
    Member since:
    Nov 2006

    Posted 25 Sep 2009 Link to this post

    I was having the same issue. I found that when I had started off I was using the automatic features but then later dropped them in favor of doing things manually. I had forgotten to set AllowAutomaticInserts="True" back to false. From your post I can't tell too much about what your situation is, but if this applies to you I suggest trying it.

    Also, I found my solution by quickly rebuilding another grid on another page to the point where it could be tested. Then I compared the properties and noticed what was different.

    Ed C.
  4. Brian Roy
    Brian Roy avatar
    4 posts
    Member since:
    Oct 2007

    Posted 25 Sep 2009 Link to this post

    I have tried it with validation and it without validation. The GridEditCommandColumn opens it up but the Insert and Update links  are the ones that are having the issue. The problem is when you implement onInsertcommand and onUpdateCommand methods auto insert and updates must be set to false. I hammered all the possible combinations I could think of and Ed C. Was right on the money. Thanks for all your help.

    //So the solution is set these to false
    // When you have these
  5. Echarbeneau
    Echarbeneau avatar
    21 posts
    Member since:
    Nov 2006

    Posted 29 Sep 2009 Link to this post

    Thanks for reporting back, and I'm glad that my suggestion worked out for you. I burned a good hour or two with this my self and was wondering if the grid should throw some sort of error in place of this odd behavior.

  6. Reginardo
    Reginardo avatar
    1 posts
    Member since:
    Dec 2016

    Posted 06 Mar in reply to Echarbeneau Link to this post

    That's works for me. Thanks!
  7. frederic
    frederic avatar
    4 posts
    Member since:
    Sep 2014

    Posted 27 Mar Link to this post

    You may also come across the situation if you have ajaxified your RadGrid because you are experiencing a partial postback of your page.   If you have an "OnRequestStart" RadAjaxManager event handler for your page, you can catch the event firing when you click the "Insert" button.  check the event target out to see if it is coming from your grid insertion click.

    if so, you may want to set_enableAjax to false for that specific request and see if that helps.

    I have something to the effect of the following and my RadGrid now successfully exits the "edit mode" of the grid.  Note that I am using a UserControl to configure the mode of the grid.


    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest" >
                <ClientEvents OnRequestStart="onRequestStart" />



    function onRequestStart(sender, args) {
       //this is the client event RadAjaxManager handles
       var eventTarget = args.get_eventTarget();
       //this is the command that can be modified before it is sent to the requester
       var eventArgs = args.get_eventArgument();
       if (eventTarget.indexOf("btnInsert") > -1) {

    .aspx (insert button)

    <telerik:RadButton ID="btnInsert" runat="server" ButtonType="StandardButton" Skin="Sunset" Text='<%# Container is GridEditFormInsertItem ? "Insert" : "Update" %>' CommandArgument='<%# Container is GridEditFormInsertItem ? "PerformInsert" : "Update" %>' CommandName='<%# Container is GridEditFormInsertItem ? "PerformInsert" : "Update" %>' />


    RadGrid definition

    <telerik:RadGrid ID="AuthoritativeDataGrid"


    insert handler

    protected void AuthoritativeDataGrid_InsertCommand(object sender, GridCommandEventArgs e)
        UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
        System.Data.SqlClient.SqlCommand command = _utilities.insertAuthoritativeData([inputs]);
        System.Data.DataTable results = _utilities.executeSqlCommand(command);
Back to Top