Home > DeveloperSection > Articles > RadioButtonList Control in ASP.Net

RadioButtonList Control in ASP.Net


ASP.Net ASP.Net 
Ratings:
2 Comment(s)
 5830  View(s)
Rate this:

RadioButtonList Control in ASP.Net

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 Control in ASP.Net

 

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;

    }

 

RadioButtonList Control in ASP.Net

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>

RadioButtonList Control in ASP.Net


Hello Sir

By Arush Raj on   5 years ago
Can You plz tell me how can I use it better in GUI application.

Radio button list control in windows application.

By Awadhendra Tiwari on   5 years ago
Hi Arush,
Whatever 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.

Don't want to miss updates? Please click the below button!

Follow MindStick