BindingSource problems on Save

BindingSource problems on Save

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


awsisme posted on Tuesday, April 17, 2007

I've been beating my head against the wall for a week on this and am fairly certain i've done something stupid archtecturally. Any help would be appreciated.

The root of my problem is this; I have a hierarchy of user controls in my winforms app which I re-use in a number of places. As a result, I've built them fairly granularly. The structure looks something like this:

   MainForm

            Account Details control

                     Account Address control

                     Account Contact control

                     etc....

The MainForm is just a container with a menuing system. The Account Details control has some unique UI components and then pulls together some other user controls to complete it's interface. At this point, the Account Details control and the sub controls each have their own BindingSource control. I create my CSLA biz object (editable root w/ child collections) inside the Account Details control and pass the object in to the child controls through their constructor. They then bind it to BindingSource controls for databinding. So, in this tree, I've got several BindingSource controls all bound to the same object. This works fine UNTIL I save changes to the object. Of course, at that point I've got a new object that has to be re-bound to the various binding sources in order to keep them in sync.

My questions are, should I be handling the BindingSource stuff differently. Is there some easy way to force an update of all the BindingSources that i'm missing?

I've gotten myself so turned around on this at this point that I might very well be missing the stupidly obvious or have just blown how I designed the code and done something stupid. Any help would be greatly appreciated.

 

Andy

RockfordLhotka replied on Tuesday, April 17, 2007

The current (2.1.4) version of CSLA .NET has an ISavable interface that exposes a Saved event you can handle in all your user controls to be notified when the object has been saved. In that event handler you can rebind to the new object (it is provided to you as part of the event).

awsisme replied on Tuesday, April 17, 2007

Rocky, thanks. I see it now. Hadn't gotten through the 2.1 docs yet. Hope you're feeling better.

 

Andy

Copyright (c) Marimer LLC