Search code examples
asp.netradiobuttonlist

RadioButtonList selected value binding in aspx


I got this RadioButtonList with defined ListItems:

<asp:RadioButtonList ID="RblSpouseLocation" runat="server" RepeatDirection="Horizontal">
        <asp:ListItem Text="In Country" Value="0"></asp:ListItem>
        <asp:ListItem Text="Outside of Country" Value="1"></asp:ListItem>
  </asp:RadioButtonList>

I have a field "SpouseLocation" of type bit in my database. I need to bind the selected value of the RadioButtonList to this field.

I found tutorials of how to do it in the code-behind, but can it be done in aspx ?


Solution

  • I changed my database field type to int and added "SelectedValue='<%# Bind("SpouseLocation") %>" to my radiobuttonlist

    The answer to this questions helped me