Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handling asp.net datasource exceptions

Tags:

c#

asp.net

I have a datasource that uses a business logic object for the select event. How can I catch an exception that occurs in the business logic layer and pass it to my presentation layer to display to the user in a label?

like image 1000
mcass20 Avatar asked Dec 01 '25 16:12

mcass20


1 Answers

You can catch datasource exceptions like this:

protected void SqlDataSource1_Selected(object sender, SqlDataSourceStatusEventArgs e)
{
    if (e.Exception != null)
    {
        // do something
        e.ExceptionHandled = true;
    }
}
like image 178
Steve Wellens Avatar answered Dec 04 '25 05:12

Steve Wellens



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!