Edit Level Mismatch when moving a child from a List of Children to the Parent

Edit Level Mismatch when moving a child from a List of Children to the Parent

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


jnthomas posted on Friday, December 04, 2009

Hello I have an annoying edit level mis-match error.

I have a List of Parents which is bound to a datagrid and I am trying to assign a Child object selected from a List of Child objects.

When I do the assignation, it eventually calls the ResetChildEditLevel but assigns the same edit level as that of the parent's which causes an edit level mis-match in AcceptChanges().

ajj3085 replied on Friday, December 04, 2009

I think this was just asked:  http://forums.lhotka.net/forums/thread/38731.aspx

jnthomas replied on Friday, December 04, 2009

I wasn't sure if I was suppose to enter in that thread since my situation is slightly different. Also the solutions posted in that thread didn't solve my problem.

To specify I tried using the .Clone() method.

ajj3085 replied on Friday, December 04, 2009

But its the same issue.  The edit levels don't match due to databinding, and when you clone it still keeps the same edit level values as the original.

jnthomas replied on Friday, December 04, 2009

When you assign the Child to the new Parent through SetProperty() it rebinds the Child to the new Parent and then calls ResetChildEditLevel() which resets the EditLevel to the new Parent. At least that's what the book states, and my traces confirm it. So I'm wondering how it goes back to the original values as you stated. I'm clearly missing something.

ajj3085 replied on Friday, December 04, 2009

But you're doing this all while databound, correct?  You can't do things "behind databinding's back," so to speak.

jnthomas replied on Friday, December 04, 2009

So you can't clone an object that is databound? Why would that be?

Copyright (c) Marimer LLC