I am using CSLA 4 release version. I have a BB -> BLB -> BB situation and some business rules on the BB child. One of the properties in the BB is a nullable int and for some reason, when i clear it in the UI (leave it empty) , neither the set property nor the businessrule get triggered. Every other time, when i change the property to an actual value, they get triggered.
Any ideas why? Is this the expected behavior?
That behavior depends entirely on the UI technology. Each technology (Web Forms, WPF, Windows Forms, etc) has a different way of handling (or not handling) nullable values, and you often need to set properties on your UI control (TextBox or whatever) to get the kind of behavior you are looking for in your UI.
Thanks so much for the quick response. Would you or someone be able to point me to what might be these properties I need to "handle"? I am using a Silverlight TextBox.
I found a resource myself. So for anyone else who stumbles here, please read this - http://jeffhandley.com/archive/2008/07/09/binding-to-nullable-values-in-xaml.aspx
Thanks again Rocky!
Hi,
If you are using Windows Forms then you must alter the NullValue on the databinding to be String.Empty (and not Null). This must be done in code and I prefer to call this in mathosd in the constructor after InitializeComponents.
Your property is never set because databinding is unable to convert the textbox value into Null.
(WindowsForms databinding does not work well by default with null values).
Alternatively attach your own code to the Parse event on the databinding for converting the textvalue into your nullable type.
Copyright (c) Marimer LLC