Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
8920
Postponing btached updates
posted

I have a whdg in batch mode... so I have a button on the page that trigger a postback and all batched updates get executed by firing rowupdating event...

If I have second button on the form, that initiate postback, is there a way to prevent somehow rowupdating events get fired and reserve them only get fired when first button pressed without losing data when second button used.

Thanks

  • 8736
    Verified Answer
    posted

    Hello Michael,

    In order to implement the functionality you described I would recommend you to use nest WebHierachicaldatagrid and the save button in one update panel and other buttons in another update panel to keep the values in grid while post back is caused by outside buttons.

    However the RowUpdating event will still fire. In order to prevent executing the code for the RowUpdating event you can use hidden filed and set it value based on the outer button click in the client side button click event as shown below:

    <asp:UpdatePanel ID="Update2" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Button ID="Button2" runat="server" Text="AnotherButton" OnClick="Button2_Click" OnClientClick="sethidden()" /> <asp:HiddenField ID="hidden1" runat="server" /> </ContentTemplate> </asp:UpdatePanel>

    function sethidden()

     {

     var hiddenfield = document.getElementById("hidden1");

    hiddenfield.value = "set";

    }

    protected void WebHierarchicalDataGrid1_RowUpdating(object sender, RowUpdatingEventArgs e)     {    

         if (hidden1.Value == "set")      

           return;

    //Updating code goes here.   

      }

    WebHierachicalDataGrid in another update panel.

    I hope this helps.