I created a method to handle the RowChanging event to validate some data in
a databound form. I am using BindingManagerBase.EndCurrentEdit to trigger
the RowChanging event. If the data cannot be validated then an exception
is raised in the RowChanging event and catched after the call to
EndCurrentEdit. The problem I am having is that after calling
EndCurrentEdit and raising the exception inside the RowChanging handler,
the values in the controls in the form that are not modified again are not
fetched again. For example...
I have a form with 2 edit boxes which are data bound. Edit1 and Edit2.
The original values for each are "mary" and "smith" respectively. If I
modify Edit1 to contain "John" and call EndCurrentEdit, the RowChanging
event is fired. If I check the Current version of the column it contains
"Mary" and the proposed version contains "John". If I raise an exception
within the event handler then the data is not saved to the dataset as
expected. At this point I still have the edit boxes containing "John" and
"Smith"... I am not calling CancelCurrentEdit because I don't want to roll
back to the current values... I am simply letting the user know that the
data entered is incorrect.
If at this point I edit the Edit2 to "Roberts" and call the EndCurrentEdit
method, the RowChanging event is fired... but if I check the proposed
version of the Edit1 bound column, it contains the Current value "Mary" and
NOT the value currently in Edit1. If the user does not edit the Edit1
control directly, the value is not reflected when EndCurrentEdit is called.
Thanks,
Jeronimo