how to allow for null value with RadioButtonList

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.
 
C

Christopher Reed

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, '').
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top