views:

376

answers:

2

The exception is throwed by database caused a conflicting by FOREIGN KEY.

+1  A: 

look at the eventargs on the ObjectDataSource. There should be an e.Exception & e.Results that you can query for the success/error of your update.

protected void MyOds_Updated(object sender, ObjectDataSourceStatusEventArgs e)
{
    if (e.Exception != null)
    {
        // handle exception here.
    }
}
Scott Ivey
Thank you so much.But I found that my problem is still exist. The exception occur on the Update-event while the Updated-method has not responded. Must I override the ObjectDataSource.Update() or ObjectDataSourceView ?
A: 

Hi,

To tell the ObjectDataSource to not rethrow your exception, you have to set the ExceptionHandled flag to True.

protected void MyOds_Updated(object sender, ObjectDataSourceStatusEventArgs e)
{
    if (e.Exception != null)
    {

        //this tells the ObjectDatasource : It's ok, i'm taking care of this
        //and don't rethrow it.
        e.ExceptionHandled = true

        // handle exception here (log/display to user etc ...)
    }
}

I hope this will help you.

Manitra.

Manitra Andriamitondra