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
650
Handling errors on WHDG with CustomAjaxResponse
posted

Hello,

I would like to handle errors like the documentation provided for WDG. I can handle RowAdded/Deleted/Updated events and then modify the EditedEventsArgs.

I use code like that :

 

WebHierarchicalDataGrid1.GridView.CustomAJAXResponse.Message = e.Exception.Message;

WebHierarchicalDataGrid1.GridView.CustomAJAXResponse.Tag =

 

"Error";

 

But I'm unable to handle the ajaxresponse on client side for events coming from child band.. It works for the root one, but not for childs...

You can look at the sample I provide, the form to use is WHD3bis.aspx

Thanks for your help !

Gregory.

WHDG_EditorsInherit.zip
  • 19693
    Verified Answer
    posted

    Hello Gregory,

    Thank you for posting in our forums.

    The issue happens because e.get_gridResponseObject().Tag is empty string

    In order to get the required result you should modify HandleError method by casting the sender to ContainerGrid.

            protected void HandleError(object sender, Infragistics.Web.UI.GridControls.EditedEventArgs e)

            {

                ContainerGrid grid = (ContainerGrid)sender;

                if (e.Exception == null)

                {

                    // Set exception message to pass to client  

                    grid.GridResponse.Message = "Exception thrown in WebHierarchicalDataGrid1_RowUpdated";

                    // Set reason for exception               

                    grid.GridResponse.Tag = "Error";

                    // Set that server-side exception is handled

                    e.ExceptionHandled = true;

                }

            }

    Thus you will always have the current Container grid ( not the one of the GridView)

    Also please keep in mind to handle the RowUpdated event of the child bands:

    protected override void OnInit(EventArgs e)

            {

                base.OnInit(e);

                WebHierarchicalDataGrid1.Bands["SqlDataSource2_DefaultView"].RowUpdated += new RowUpdatedHandler(WebHierarchicalDataGrid1_RowUpdated);

                WebHierarchicalDataGrid1.GridView.RowUpdated += new RowUpdatedHandler(WebHierarchicalDataGrid1_RowUpdated);

            }

     

            protected void WebHierarchicalDataGrid1_RowUpdated(object sender, RowUpdatedEventArgs e)

            {

                HandleError(sender, e);

            }

    Let me know if you need further assistance