Object fails if radio button is not checked

Object fails if radio button is not checked

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


GrullonM posted on Thursday, January 04, 2007

I have a form with many different controls (textboxes, labels, radio buttons, etc..)

The RadioButtonLists bind to Boolean values (bit data type in SQL Server) and are used just for Yes/No answers.

Null values are allowed in the database on this column for a specific reason and the issue I am having with the application is that I can't submit the form (it fails) if I don't check the radio buttons on the form.

Any ideas?

RockfordLhotka replied on Thursday, January 04, 2007

When you say "can't submit the form" do you mean that the browser won't do the postback, or that the object is either throwing an exception or is becoming invalid (IsValid is false)?

If you really can't do a postback then you are out of my area of expertise and it is probably some html thing.

But if you are having issues with the object, it may be that you need to support null values for your property. If the property is a Boolean value then it must be true or false. If you want to support null, you'll probably want to use Nullable<T> as the type for that property (and its backing field).

GrullonM replied on Thursday, January 04, 2007

I am having issues with the object itself and you are abolutely right, I need to set Null on my property but did not know where to add it.

I checked page 322 of the book(vb) and see how you implement nullable in your framework. How do I make my property nullable?

Thanks!

RockfordLhotka replied on Thursday, January 04, 2007

 
  Dim mField1 As Nullable(Of Boolean)
 
  Public Property TheValue() As Nullable(Of Boolean)
 
 
     


From: GrullonM [mailto:cslanet@lhotka.net]
Sent: Thursday, January 04, 2007 1:15 PM
To: rocky@lhotka.net
Subject: Re: [CSLA .NET] Object fails if radio button is not checked

I am having issues with the object itself and you are abolutely right, I need to set Null on my property but did not know where to add it.

I checked page 322 of the book(vb) and see how you implement nullable in your framework. How do I make my property nullable?

Thanks!




Copyright (c) Marimer LLC