Design By SLS
New Member
I'm wondering what the proper way to handle insertion errors into my database is?I obviously want to present the user with an error while still preserving the viewstate.I use a detailsview to insert the data into the database but due to database constraints some values are not allowed which raises an exception.I tried using the OnInserted event and checking for an exception, the problem seems to be that if i mark the exception as handled it will not preserve the viewstate of the form. The code looks like this:\[code\]protected void areaInsertHandler(Object sender, SqlDataSourceStatusEventArgs e){ if (e.Exception != null) { // There was an error in submitting, show the error dialog ScriptManager.RegisterClientScriptBlock(Page, GetType(), "DialogHandler", "showError('#overlayAreas');", true); e.ExceptionHandled = true; }}\[/code\]The code simply displays an error notification using javascript, but the values into the form are not preserved.So, what is the proper way to handle this type of error?Thanks!