Binding CheckBox to BO for Window Application

Binding CheckBox to BO for Window Application

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


davidng posted on Monday, February 07, 2011

Hi everyone,

Please help with this issue for Windows Application.

In my Oracle database table Employee, I have a 1-character column called Manager_Indicator

In my BO, 

Private  _Manager_Ind_Boolean String = String.Empty

Public Property Manager_Ind_Boolean() As Boolean

Get
    Return
IIf(_Manager_Ind.ToUpper = "Y", True, False )
End  Get

Set(ByVal value As Boolean )
   _pwgscInd = IIf(value =  
True, "Y", "N" )

End Set

 

End Property

In my UI, using a checkbox to diplay Manager Indicator (checked for "Y", unchecked for "N").

I am using BindingSource for BO obContract.

And Checked property of checkbox binds to Bindingsource. Manager_Ind_Boolean

When I save this object, I get error object is invalid & can not save.

Thanks you in advance for your help.

 

davidng replied on Monday, February 07, 2011

There is a typo, correct one is:

Private  _Manager_Ind as String = String.Empty

JonnyBee replied on Monday, February 07, 2011

If the object is Invalid then you still have broken rules. So check the BrokenRulesCollection to find out which rule is broken and why.

If you have a StringRequired rule on the backing value then it will never get called when the property is changed as you do not call PropertyHasChanged in your setter.

davidng replied on Tuesday, February 08, 2011

Hi Johnny,

Thank you for your advise. I did find the error.

 

ajj3085 replied on Monday, February 07, 2011

In addition to what Jonny said, I found that usually this kind of transation was done because i had to put a Y or N in the database.  I found I much prefered to handle this when loading / saving the BO, than relying on a string backing field for something that really is a boolean.

Copyright (c) Marimer LLC