A duplicated record created if if user double clicks on Insert button of the ASP.Net hierarchical grid

1 Answer 123 Views
Top achievements
Rank 1
Mircea asked on 22 Nov 2022, 12:55 PM

Using ASP.Net hierarchical grid, version 2022.2


User is creating a new child record and attempts to save it. However, instead of just clicking the Save button, user double-clicks on it.


INSERT command gets fired twice and two duplicated child records are created, with different ID's.

This issue is very easy to reproduce. How to avoid it? 


1 Answer, 1 is accepted

Sort by
Attila Antal
Telerik team
answered on 25 Nov 2022, 10:22 AM | edited on 25 Nov 2022, 04:29 PM

Hello Mircea,

You can enable AJAX for the Grid with a Loading panel. As soon as you have clicked the save button, the loading panel will show up covering the entire Grid as a result preventing further clicks.

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1">
        <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <telerik:AjaxUpdatedControl ControlID="RadGrid1" />

<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default" MinDisplayTime="600"></telerik:RadAjaxLoadingPanel>

<telerik:RadGrid ID="RadGrid1" runat="server" OnNeedDataSource="RadGrid1_NeedDataSource">





Another easy way to prevent double-clicking on the Insert/Update buttons is by using an EditForm Template. Within the template, you can use RadButton for Insert/Update commands and set its SingleClick  (Single Click Button) property to false. This, however, requires that you create the entire layout for editing/inserting.

<EditFormSettings EditFormType="Template">

        <%--Create a custom layout with your own Form Controls to Insert/Update--%>

        <%--The Insert/Update/Cancel buttons--%>
        <telerik:RadButton runat="server" ID="RadButton1" 
            Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update"  %>' 
            CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update"  %>' AutoPostBack="true" SingleClick="true" />

        <telerik:RadButton runat="server" ID="RadButton2" Text="Cancel" CommandName="Cancel" AutoPostBack="true" />



If you'd rather skip creating a completely new EditForm layout and avoid using AJAX, perhaps this option would fit you better.

Using the GridCreated client-event, you can attach a click event listener to all Insert/Update buttons that are rendered, and when they are clicked, show an AjaxPanel explicitly


<telerik:RadGrid ID="RadGrid1" runat="server">
        <ClientEvents OnGridCreated="OnGridCreated" />

<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default">

    function OnGridCreated(sender, args) {
        var $updateButtons = $telerik.$(sender.get_element()).find('.rgEditForm .rgActionButton.rgUpdate, .rgEditRow .rgActionButton.rgUpdate');

        $updateButtons.each(function(index, button) {
            $telerik.$(this).on('click', function(e) {
                var ajaxLoadingPanel = $find("<%= RadAjaxLoadingPanel1.ClientID %>");

Note: This will work with the EditModes EditForms, PopUp, and InPlace.

Attila Antal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Top achievements
Rank 1
commented on 25 Nov 2022, 01:53 PM | edited


Thank you Attila, I added the code you suggested, it works however...... I would like it to work only when saving and updating a record (clicking on Save button), not when I edit a record. Please advise if possible.

Please also modify the following line of code in your initial response to set DefaultLoadingPanel property

<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="RadAjaxLoadingPanel1">

Attila Antal
Telerik team
commented on 25 Nov 2022, 04:26 PM

Hi Mircea,

I have updated my initial answer with two more scenarios. I hope they will help achieve what you are looking for.

Top achievements
Rank 1
commented on 25 Nov 2022, 04:29 PM

Thank you Attila for your help, this issue is resolved.


Attila Antal
Telerik team
commented on 25 Nov 2022, 04:31 PM

Thanks for confirming it back. I have marked my answer. 

Happy coding!
Asked by
Top achievements
Rank 1
Answers by
Attila Antal
Telerik team
Share this question