Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all articles
Browse latest Browse all 7205

How to show an error message when a record cannot be deleted

$
0
0

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

Added By: Jay Johnson at: 3/24/2016 6:05:38 PM    This was very nice to find!Added By: Hal Burch at: 8/26/2016 7:21:11 AM    This example doesn't work when I download it and run it in VS. I get the MyException was unhandled by user code.Added By: Helen (DevExpress Support) at: 8/26/2016 8:28:11 AM    

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.


Viewing all articles
Browse latest Browse all 7205

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>