Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to catch entitydatasource exception

I have a gridview that is bound to a entitydatasource.I've creaetd this using drag and drop from the asp.net controls in the toolbox, and using an entity data model.I have had little input in the codebehind. For testing purposes I have edited the gridview and added data that is invalid. I've then clicked update to cause an exception.

So my question is I would like to try and catch the exception in my own error handler but I don't know where or how I can do this as I'm not sure which event I should be focusing on. I would just like to know where to begin with this.

Many thanks

like image 614
mjroodt Avatar asked Mar 07 '26 22:03

mjroodt


1 Answers

You can trap the exception in the OnUpdated event of the EntityDataSource:

protected void EntityDataSource1_OnUpdated(object sender, EntityDataSourceChangedEventArgs e)
{
   if (e.Exception != null) 
   {
         // handle here
          e.ExceptionHandled = true;
   }
}

}

like image 109
Rob Sedgwick Avatar answered Mar 10 '26 13:03

Rob Sedgwick