I have 5 different entities for which dynamic data(with LINQTOSQL) was generated. On Insert(Insert.aspx) of any of these entities, if there is an error, I would like to notify user that error happened and possibly show some generic error message.
1) I am not talking about regular required field errors but something like "Unique constraint violation"
2) I can do it for each page separately by doing something like this:
protected void DetailsView1_ItemInserted(object sender, DetailsViewInsertedEventArgs e) {
if (e.Exception == null || e.ExceptionHandled)
{
Response.Redirect(table.ListActionPath);
}
else
{
//OtherErrors is the label on the page
OtherErrors.Visible = true;
OtherErrors.Text = e.Exception.Message;
OtherErrors.DataBind();
e.ExceptionHandled = true;
e.KeepInInsertMode = true;
}
}
3) BUT, I want to created something very generic that will work for all inserts across all entities