The RadioButtonList control is used to create a group of radio buttons.
RadioButtonList are used when we need to make multiple sets of choices available, but we want the user to select only one of them. If they click on a second selection after making a first, the first selection is removed.
RadioButtonList also supports data binding.
<asp:RadioButtonList ID="RadioButtonList1" runat="server">
<asp:ListItem>c#</asp:ListItem>
<asp:ListItem>j#</asp:ListItem>
<asp:ListItem>vb</asp:ListItem>
<asp:ListItem>c++</asp:ListItem>
<asp:ListItem>c</asp:ListItem>
</asp:RadioButtonList>
RadioButtonList event
The default event of the RadioButtonList is the SelectedIndexChanged
<asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True"
Font-Bold="True" Font-Italic="True" Font-Names="Arial" ForeColor="Red"
onselectedindexchanged="RadioButtonList1_SelectedIndexChanged">
<asp:ListItem>c#</asp:ListItem>
<asp:ListItem>j#</asp:ListItem>
<asp:ListItem>vb</asp:ListItem>
<asp:ListItem>c++</asp:ListItem>
<asp:ListItem>c</asp:ListItem>
</asp:RadioButtonList>
protected void RadioButtonList1_SelectedIndexChanged (object sender, EventArgs e)
{
Label1.Text = RadioButtonList1.SelectedItem.Text;
}
When you select any option then SelectedIndexChanged event will fire and it will show the selected value in Label.
We can change RadioButton appearance
<asp:RadioButtonList ID="RadioButtonList1" runat="server" Font-Bold="True"
Font-Italic="True" Font-Names="Arial" ForeColor="Red"
onselectedindexchanged="RadioButtonList1_SelectedIndexChanged">
<asp:ListItem>c#</asp:ListItem>
<asp:ListItem>j#</asp:ListItem>
<asp:ListItem>vb</asp:ListItem>
<asp:ListItem>c++</asp:ListItem>
<asp:ListItem>c</asp:ListItem>
</asp:RadioButtonList>
Anonymous User
27-Jul-2011Whatever I understand your requirement is that you want to perform same functionality in windows application using c#.
Visual c# does not provide direct way to handle this task. Except for performing this task you have to use any container control such as panel or groupbox which holds your radio button control. Then you can put all radio button on that container control and you see that you are able to select only one of them.
I hope you understand what I want to say. If you got any further problem to implementing this task then feel free to ask it on here or you can ask it on mindstick forum.
Thanks.
Arush Raj
19-Jul-2011