StrataFrame Forum

Mapping a field

http://forum.strataframe.net/Topic29935.aspx

By Willie van Schalkwyk(1) - 5/2/2011

Hi all

I suppose this is a elementary question but I am totally new so please bear withSmile



I have a field called Sex char(1) where the values can either be "M" or "F". I want to use a radio button for the selection where the values of the Radio button must be Male and Female. I would like to specify the value within the BO. Is this possible.

Thanks

Willie

 
By Greg McGuffey - 5/3/2011

I'd create a custom, bindable field in the BO that translates the "M"/"F" into 1 and 2 (which can then be bound to the radio button group).  See the Adding Custom Field Properties topic in the SF help file for more information on custom fields.
By Willie van Schalkwyk(1) - 5/4/2011

Thanks Greg

Done it and now the form is displaying. However, when I would edit it and select a value it runs into a neverending loop within the set.

Here is the custom property code :

#Region " Custom Field Properties "

''' <summary>

''' sex

''' </summary>

<Browsable(False), _

BusinessFieldDisplayInEditor(), _

Description("Sex Radion button field"), _

DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)> _

Public Property [sex_radion]() As System.Int32

Get

Dim loValue As Object

loValue = Me.CurrentRow.Item("sex")

If loValue Is DBNull.Value Then

Return 1

Else

If loValue = "F" Then

Return 2

Else

Return 1

End If

End If

End Get

Set(ByVal value As System.Int32)

If value = 1 Then

Me.CurrentRow.Item("sex") = "M"

Else

Me.CurrentRow.Item("sex") = "F"

End If

End Set

End Property

#End
Region

 

I also added the follwoing:

Protected Overrides Function GetCustomBindablePropertyDescriptors() As MicroFour.StrataFrame.Business.FieldPropertyDescriptor()

'-- Create and return a new array of FieldPropertyDescriptor

' objects that contains the ReflectionPropertyDescriptor

' for the cust_fullname field.

Return New MicroFour.StrataFrame.Business.FieldPropertyDescriptor() { _

New MicroFour.StrataFrame.Business.ReflectionPropertyDescriptor( _

"sex_radion", GetType(AgentBO))}

End Function

By Greg McGuffey - 5/5/2011

I'm not seeing anything obvious in this code that would start an infinite loop.  I'd step through the code, starting with whatever action causes the loop to occur. Likely you have some other code that is responding to this action that is causing the loop.
By Willie van Schalkwyk(1) - 5/5/2011

Hi Greg

Ok, got the problem. In my radio button, hidden behind the other there were another 3 buttons. It seemed that the value of one of them also had a value of 2.

Thanks for the help.

Willie