C #: Null database in RadioButtonList
I would like to have a ham radio if you can choose null.
Something like that:
<asp:RadioButtonList ID="rblCD" runat="server" SelectedValue='<%# Bind("tblCD") %>'>
<asp:ListItem Value="RW">RW</asp:ListItem>
<asp:ListItem Value="R">R</asp:ListItem>
<asp:ListItem Value="DBNull">None</asp:ListItem>
</asp:RadioButtonList>
Thanks a lot, Vincent
+2
a source to share
3 answers
The values in the radioobuttonlist are always strings. You would have to do something like this
<asp:ListItem Value="">None</asp:ListItem>
Then when you read data from the control, do something like
if (rblCD.SelectedValue == string.Empty)
{
MyDataRow["Column"] = DBNull.Value;
}
+1
a source to share