ChildCollection BindingSource.CancelEdit Problem

ChildCollection BindingSource.CancelEdit Problem

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


renegrin posted on Thursday, January 17, 2008

I am using CSLA 3.02 and experiencing a problem. When implementing a Cancel Button subroutine as stated in the Using CSLA.Net Version 3.0 page 120, unbinding any of the ChildBindingSources does not undo the add, delete or editing Child item changes of that respective ChildCollection.  When unbinding the ParentBindingSource, the undo works fine on attributes in the Parent object, but  ChildCollection attributes remain unchanged.

 

We have a ParentObject with 3 ChildCollectionObjects attached. The ParentObject is bound to ParentBindindSource component and each ChildBindingSource is bind to ParentBindingSource and its DataMember set to proper childcollection.

 

Any ideas? Thanks in advance.

RockfordLhotka replied on Thursday, January 17, 2008

You need to follow the pattern used in the edit forms in PTWin, which is slightly more complex than the code in the ebook.

Specifically, before binding your objects you need to manually call BeginEdit() on the root object.

Then, after unbinding your objects you need to manually call CancelEdit() on the root object. Or ApplyEdit() if the user clicked the Save button.

renegrin replied on Thursday, January 17, 2008

Thanks will try that.

renegrin replied on Thursday, January 17, 2008

We got it working. Two of us were working on this. Much thanks.

Copyright (c) Marimer LLC