This example demonstrates how to show an error message when an attempt to delete a record is cancelled by the RowDeleting event handler.
Question Comments
Added By: Rabab Siblini at: 3/16/2016 11:18:39 PM Tanks, it works exactly as I want , but I didn't user the exception class , I check it as such :
protected void gvDiscounts_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e) { if (CannotDelete) throw new Exception("DeleteError"); }
protected void gvDiscounts_CustomErrorText(object sender, ASPxGridViewCustomErrorTextEventArgs e) { if (e.Exception.Message == "DeleteError") e.ErrorText = e.Exception.Message; } Added By: Vova (DevExpress Support) at: 3/17/2016 1:57:07 AM
Thank you for sharing your idea with our community, Rabab. It may be useful for other users trying to complete a similar task.
Best regards,
Vova
Hello Hal,
This example illustrates how to handle errors that occurs on row deletion. In this example, the "MyException" is thrown there intentionally to emulate an exception on deletion. If you choose to continue code execution after the exception, it will show the custom error text specified in the ASPxGridView.CustomErrorText event handler as expected.