'Setting the selected value of asp:RadioButtonList

I have a radiobuttonList and i find the following solution to set the selected value using the code behind.

  RadioButtonList1.Items.FindByValue("1").Selected = true;

I was wondering if there was a solution without using the code behind. Below code is not working obviously, but i want to do somehting like the following. Thanks in advance

   <asp:RadioButtonList ID="ItemValue" runat="server" Width="109px" value="<%# Bind("ID")%>">
                <asp:ListItem Value="1">Test1</asp:ListItem>
                <asp:ListItem Value="2">Test2</asp:ListItem>
   </asp:RadioButtonList>


Solution 1:[1]

Try to use the SelectedValue instead of Value when using Binding

Solution 2:[2]

rematnarab - Either methods should work - Your method sets the required item's selected property to true, but DOES NOT SET other items to false.

Therefore ASPaiva's method is the better way, however note, if the SelectedValue is set to a value that is not in the radio buttons item list, nothing will happen.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 ASPaiva
Solution 2 Vijay Jagdale