4

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

Scott Ivey
  • 40,768
  • 21
  • 80
  • 118

3 Answers3

4

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
  • 40,768
  • 21
  • 80
  • 118
  • 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 ? –  May 14 '09 at 02:38
3

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
  • 1,249
  • 1
  • 15
  • 21
0

if this is not helping use the grid view update method

If Not e.Exception Is Nothing Then
    e.KeepInEditMode = True
    e.ExceptionHandled = True
    msg("error .", "a", Me.GetType(), ClientScript)
End If
John Koerner
  • 37,428
  • 8
  • 84
  • 134
Ram
  • 1