I have a web page with a LLBLGenProDataSource (SelfServicing) with LivePersistence=false databound to a FormView. When inserting a new entity and an exception occurs (due to entity Validator or any other reason) in PerformWork event, it is caught in ItemInserted event of the FormView so I display an error message in the form while preserving the form values. When the form is resubmitted the form changes are not updated to the UnitOfWork and the old values are persisted.
To reproduce this use the sample project WebDataBinding_06062008, SelfServicingWebApp2, Employee.aspx page. In EmployeeDetailsDS_PerformWork throw a generic exception before e.Uow.Commit line and add the following to the EmployeeFormView_ItemInserted:
if (e.Exception != null)
{
e.ExceptionHandled = true;
e.KeepInInsertMode = true;
// add a label to the FormView to display the exception message
//Label lblException = frmEditCreditCard.FindControl("lblException") as Label;
//if (lblException != null)
//{
// lblException.Text = e.Exception.Message;
//}
}
Set a break point at line 188, SetPicture(entityToInsert); and try to submit a new Employee. After the first try make a change to the value of one of the textboxes and resubmit again. Once the debugger stops at the breakpoint check the value of the changed property of the entityToInsert and will notice it had not been changed between submits.
Everything works as expected when updating existing entities.
Thank you,
Val