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
535
How to cancel UpdateRowBatch
posted

I have a grid that the user can add/update/delete data and then pressing the SAVE button let's me make the changes to the db via the xxxbatch events. I would like a cancel button on the screen that would postback but allow me to cancel the changes. Of course, the btnCancel_click event occurs after the grid's batch events. Any clue how to cancel the changes? thanks!

  • 29417
    Suggested Answer
    Offline posted

    Hello rdorris ,

     

    I know it has been a while since you posted your question in our forum but if you still need help regarding this issue I’d be glad to answer your questions.

     

    The best approach is to check which control has triggered the event like this:

     

    public static Control GetPostBackControl(Page page)

        {

            Control control = null;

     

            string ctrlname = page.Request.Params.Get("__EVENTTARGET");

            if (ctrlname != null && ctrlname != string.Empty)

            {

                control = page.FindControl(ctrlname);

            }

            else

            {

                foreach (string ctl in page.Request.Form)

                {

                    Control c = page.FindControl(ctl);

                    if (c is System.Web.UI.WebControls.Button)

                    {

                        control = c;

                        break;

                    }

                }

            }

            return control;

        }

     

    Then make a check if that control is the Cancel Button and if it is set a Boolean flag  to true and in the UpdateRowBatch do:

     

    protected void UltraWebGrid1_UpdateRowBatch(object sender, Infragistics.WebUI.UltraWebGrid.RowEventArgs e)

        {

            if (flag)

            {

                e.Cancel = true;

                flag = true;

     

            }

        }

     

    I’m attaching a sample with this for your reference. Let me know if you have any further questions or concerns regarding this issue.

     

     

     

     

    Best Regards,

    Maya Kirova

    Developer Support Engineer

    Infragistics, Inc.

    http://ko.infragistics.com/support

     

    UWG_CancelRowBatchUpdate.zip