articles

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

RadioButtonList Control in ASP.Net

Pushpendra Singh10889 14-Oct-2010

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


Updated 04-Mar-2020

Leave Comment

Comments

Liked By