Undoable object problem (edit level synchronization)

Undoable object problem (edit level synchronization)

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


pandelaras posted on Wednesday, November 21, 2007

Hello All,

I am working on a Csla project which incudes an Editable root parent Object that contains a child list . Typical project and projectresources situation (from projecttracker sample). I am using a second Form to add Lines to my collection. Removing lines is pretty easy also.I dont have any edit level problems there. The problem is i get an "edit level mismatch in copy state error" when i try to modify the line and keep the object synchronised.

This is what i tried so far. (all of these create the error).  Passing the line object to the second form, changing the values there and afterwards

1) copying the values from one object to the other.

2) removing the old object and adding the new one

I did try to applyedit before passing it to the collection and it worked but when i  cancelled all changes on the parent object, it caused the changed line to disappear. While removing the line object i use the .removecurrent() method of my bindingsourceobject. Cancelling changes works fine that far. Adding the new line to the list and then cancelling changes cause the new line to dissappear. Am i doing sth totally wrong here?

pandelaras replied on Thursday, November 22, 2007

I believe i found the solution.

My question could be rephrased as " How would u put a change button on a form like Projectracker?"

It seems that when i was passing the child object to the second form i was using the instance reference. What i should be doing was to use the clone method on the current instance and then pass it on. Finally i used a simple method to transfer the values of changed instance to the original one, just to be sure. That worked for me!

RockfordLhotka replied on Friday, November 23, 2007

Your only other option is to unbind the child object from the first form, then bind it to the second form. Then unbind it from the second form when that form is closed, and rebind it to the first form.

Copyright (c) Marimer LLC