mcass20
mcass20

Reputation: 1688

Handling asp.net datasource exceptions

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?

Upvotes: 3

Views: 700

Answers (1)

Steve Wellens
Steve Wellens

Reputation: 20620

You can catch datasource exceptions like this:

protected void SqlDataSource1_Selected(object sender, SqlDataSourceStatusEventArgs e)
{
    if (e.Exception != null)
    {
        // do something
        e.ExceptionHandled = true;
    }
}

Upvotes: 3

Related Questions