user3340627
user3340627

Reputation: 3143

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 ?

Upvotes: 0

Views: 3241

Answers (1)

user3340627
user3340627

Reputation: 3143

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

The answer to this questions helped me

Upvotes: 1

Related Questions