how to allow for null value with RadioButtonList

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

On my aspx page I have a FormView with a RadioButtonList bound to a column on
a DataSource table. The form starts up in Edit mode. I want the formView to
start up with nothing yet selected in the RadioButtonList. Is there a way to
do this? With null in the table/column, I get a startup error complaining
the SelectedValue is invalid because it does not exist in the list of items.
Thanks very much if someone has a way to solve this problem.
 
What you are can do is within your SELECT statement that you're using to
populate your FormView, test for the NULL value in your table and return an
empty string in place of it. The default SelectedValue for a
RadioButtonList is an empty string, meaning that no values have been
selected.

In SQL, replace your field in the SELECT with COALESCE(fieldname, '').
 
Back
Top