protected override void OnChildChanged(Csla.Core.ChildChangedEventArgs e) does not fire after .Save

protected override void OnChildChanged(Csla.Core.ChildChangedEventArgs e) does not fire after .Save

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


Lord02 posted on Sunday, May 30, 2010

Hi there,

I'm having a really weird problem using CSLA 3.8.X ...

I'll try to explain in as simple way I can:

I have 3 level CSLA objects ( e.g. parent, child, grandchild ) bound to a Infragistics UltraGrid ( version 2010 ). Using WinForms solution.-
I have a "CanSave" property in a "MasterClass" which is responsible for the whole form ... this "CanSave" property is bound to a Save button on the form, and if the CSLA classes which are bound to the UltraGrid are valid and Save'able, the button is enabled, else it's disabled.

I have multiple forms which all use this mechanism, where I have a "MasterClass" for each form, and this MasterClass contains the datasource ( e.g. "AvailableProjects" which is a CSLA BusinessBaseList, "AvailabelBranches" which is a CSLA BusinessBaseList, "CanSave" the property I mentioned above etc ... )
- This is working very well on all the forms, and I've been using CSLA for a long time

Anyways ...
To check the validity of the Children on the form I have this:
protected override void OnChildChanged(Csla.Core.ChildChangedEventArgs e)
        {
            base.OnChildChanged(e);
        
            if (CurrentStatusList != null)
            {
                CanSave = this.IsSavable && CurrentStatusList.IsSavable;
            }
        }

And this:

public bool CanSave
        {
            get
            {
                return IsSavable && ((CurrentStatusList == null)  || (CurrentStatusList.IsSavable));
            }
            set
            {
                if (_canSave != value)
                {
                    _canSave = value;
                    PropertyHasChanged("CanSave");
                }
            }
        }


Everything is working fine untill I call the .SAVE function of the parent ... and then I rebind like I do normally
like this:
_statusManager = _statusManager.Save();

and then:
_masterStatusBindingSource.DataSource = _statusManager;

this _statusManager is this "ManagerClass" which I mentioned and it contains e.g. the "CanSave" property and all the datasources needed on the form.

but after I rebind ( e.g. the two lines above ... Save and the rebinding ) this

protected override void OnChildChanged(Csla.Core.ChildChangedEventArgs e) does not fire, ever again !!!
- So the button ( which is databound to "CanSave" property is always DISABLED after the first save, so I can never update items again, nor can I save a new one.-

I have breakpointed into the grandChild and it DOES enter the "Set" methods (Managed properties) for all the properties when it's being changed in the UI which should then trigger the OnChildChanged, but it does NOT fire the OnChildChanged ( or PropertyChanged for that matter ).

So there's something seriously wrong with the re-hooking of the parent,child,grandparents I think ....
But I cannot find what it is !
I should mention that I'm using the CodeSmith CSLA v. 1560 templates
( from here: http://community.codesmithtools.com/nightly/csla/ ) and everything has been working great throught the development process ... I'm working closely with the CodeSmith CSLA templates author to work on the templates and improving them. So far, so good. I'm REALLY fast developing a full blown databound applications databound against CSLA objects.

I hope I descripted the problem well enough, any help would be greatly appriciated.-

Kind regards,
EE.

Copyright (c) Marimer LLC