mBindingEdit inBusinessBase

mBindingEdit inBusinessBase

Old forum URL: forums.lhotka.net/forums/t/4040.aspx


Sergey68 posted on Friday, December 14, 2007

Ok, this case is convoluted, but I will try to explain the best I can,

I have a business object on a form.  Once it is created in form_load, I issue BeginEdit on it.

There is a button on that form that launches a popup form that edits a property on that object. That form has its own OK and Cancel buttons and this form directly modifies a property on my business object.  What I do to react to OK and Cancel button on popup form is the following.  I issue another BegingEdit on my main formt before popup form is launched.  Once the popup form is closed, I examine DialogResult and either issue ApplyEdit or CancelEdit on my business object depending on which button was clicked on popup form.  So far so good, once the routine is completed, EditLevel on my business object is still 1.

However, once another property on the same business object is edited on the main form, EditLevel goes to 2, causing Save function to error out with “Object is still being edited” exception.  I traced what causes this error.  Binding infrastructure calls BeginEdit on the IEditableObject (BusinessBase) during PullData call.  Issue is that mBindingEdit variable is set to False at that time, and another stack state push occurs.  Seems to me that ApplyEdit and CancelEdit should only set mBindingEdit to False if Stack length is zero, but I am not sure.

Any suggestions or opinion on this?

Thanks.

Sergey

RockfordLhotka replied on Friday, December 14, 2007

CSLA 3.0.3 includes some help and bug fixes around this area. Getting Windows Forms data binding correct is challenging.

Some help will come if you look at the PTWin example from version 3.0.3. That illustrates (and is explained in Using CSLA .NET 3.0) how to properly use data binding. Some of the bug fixes in CSLA 3.0 are also required for some in-place editing scenarios in grids, but even 2.1.4 should work pretty well if you follow the UI coding patterns from PTWin 3.0.3.

Copyright (c) Marimer LLC