How to trap errors in DetailsView control

Last post 01-28-2008, 3:47 PM by Damon. 1 replies.
Sort Posts: Previous Next
  •  01-28-2008, 2:23 PM Post number 43246

    How to trap errors in DetailsView control

    I'm trying to figure out how to trap the following error and display a more friendly message.

    DELETE statement conflicted with TABLE REFERENCE constraint 'FK

    I'm using  ASP.NET 2.0 Framework - Detailsview control using an ObjectDataSource

    I've tried placing it in the following, but no success:

    DetailView1 ItemDeleting & ItemDeleted

    ObjectDataSource1 Deleting & Deleted

    Page Load & Unload

     

     

     

  •  01-28-2008, 3:47 PM Post number 43255 in reply to post number 43246

    • Damon is not online. Last active: 11-26-2008, 11:06 AM Damon
    • Top 10 Contributor
    • Joined on 06-26-2006
    • Dallas, TX
    • Acorn Archimedes

    Re: How to trap errors in DetailsView control

    I'm not sure which event the error is occuring in, but you can catch any error that does occur by overriding the OnError method of the page and putting your custom exception handling logic in that method.

    protected override void OnError(EventArgs e)
    {
        
    Exception ex = Server.GetLastError();
         // Do your custom stuff here

        
    base.OnError(e);
    }


    Damon Armstrong, Technology Consultant
    [Blog] [Articles]
View as RSS news feed in XML