CSLA: DataGridView + BindingSource + RootObject = HUH?

CSLA. A great product that does so many things so well. I won't expound upon how much I like it at the moment, but I always feel like I should say something positive about it before I point out something odd.

 

I have a standard DataGridView in a WinForm application. I have a Root object (which children and grandchildren, although this isn't relevant). I am using a BindingSource for binding the two together. So, in my code, I have something like this:

code1

 

Now, this should seem like pretty boilerplate CSLA, and it is. Where we run into trouble is when we save the CSLA Root (nothing peculiar there):

 

code2

 

We get an exception in the DataPortal, which states: "Object is still being edited and can not be saved". Did some sleuthing about. Your BusinessBase has a private property called "EditLevel"' (which comes up through the inheritance chain). The edit level is incremented and decremented (sic) by things like BeginEdit, ApplyEdit, or CancelEdit (as a matter of fact, I think these are the only places it's changed). If the EditLevel is > 0, the object is still being edited. The DataPortal.Save makes this check. Trouble is, I am using BeginEdit (EditLevel =+ 1) and ApplyEdit (EditLevel =-1) one time each, so how could the EditLevel be anything but 0? Obviously, the BeginEdit is being called more than once, but how?

I removed the BeginEdit call in the first piece of code, and voila! It works. Clearly somewhere in BusinessBase, the DataGridView, and BindingSource, we are having a problem. As a work-around,I will bind the grid directly.

And for anyone who has noticed this is VB and not C#, I haven't given up on C#. I am writing a sample app for CodeCamp 3.0 in Charleston this weekend, and I am still more productive in VB.  :-)

«October»
SunMonTueWedThuFriSat
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910