StrataFrame Forum

RadioButtonGroup with no default value

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

By fansanitis - 2/7/2008

I've setup a RadioButtonGroup with 5 options (values 0-4) on a user control.  The designer sets the Checked property of the option with the value of 0 to True.  I manually change the property back to False and save the file.  Everythings looks fine at this point, no options with a Checked property of True.  I close the user control designer in VS and then reopen it and the option with the value of 0 is "checked" again.

I want the user control to render with no option selected and if the BO is saved without the user making a selection I want a required field broken rule to be displayed.  Can I make the RadioButtonGroup do this?

By Trent L. Taylor - 2/7/2008

Can I make the RadioButtonGroup do this?

You are fighting .NET serialization and so this value is being updated and set in the InitializeComponent method...the answer is, "Yes."  but you may, in this instance, just need to set this in the constructor or the load instead of fighting the .NET designer.

By fansanitis - 2/7/2008

Thanks Trent that works great but now I'm being tripped up by my BO the control is bound to.  The field in the database is a smallint that allows nulls.  When I configure the BO in the BO Mapper I customize the field to use a Null Type of Use Nullable Generic which is 0 for this datatype.  So when I perform a BO.Add the BO property for the field in question gets set to 0 which is the value of one of my options so it always displays with an option selected.

How should I setup the database field and BO Mapping so no option is selected on a BO.Add?  I need to use the values 0-4 for the option values since they are later used in summary calculations.

By Trent L. Taylor - 2/7/2008

Just return an alternate value on NULL and set it to a -1 or something like that.  This way you do not have a collision of values and NULL.