How to use RadioButtonList control in c#

RadioButtonList web server control
ASP.NET RadioButtonList control enable user to select an item from list. RadioButtonList support data bind programmatically from database. We can also populate it manually by input list item inside RadioButtonList tag. RadioButtonList is a single selection radio button group. RadioButtonList have an items collection. We can determine which item is selected by test it's SelectedItem property.

We can change RadioButtonList design by setting up it's various property as like BackColor, BorderColor, BorderStyle, BorderWidth, CellPadding, CellSpacing, CssClass, Font-Bold, Font-Italic, Font-Names, Font-Overline, Font-Size etc. there are more three properties RepeatColumns, RepeatDirection and RepeatLayout which help you to place list item vertically or horizontally.

RadioButtonList have standard AutoPostBack property. As like other list control RadioButtonList have an excellent event SelectedIndexChanged. So that when someone select an item it automatically post back the page and we can determine programmatically which item is selected now. For that we need to set AutoPostBack property value to true and setup a SelectedIndexChanged event. DataSourceID, DataTextField and DataValueField property help you to data bind RadioButtonList with database. RadioButtonList also support theme and skin.

In this example we demonstrate a very simple example of RadioButtonList. Select an item from RadioButtonList and submit the form by clicking button control. You will get which item is selected from RadioButtonList .

<%@ Page Language="C#" %>

<!DOCTYPE html>

<script runat="server">
    protected void Button1_Click(object sender, System.EventArgs e)
        Label1.Text ="You Selected Collection: " + RadioButtonList1.SelectedItem.ToString();

<html xmlns="">
    <head runat="server">
        <title>RadioButtonList example: how to use RadioButtonList control in</title>
        <form id="form1" runat="server">
                <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="Crimson"></asp:Label>
                <asp:RadioButtonList ID="RadioButtonList1" runat="server">
                <br />
                <asp:Button ID="Button1" runat="server" Text="Show Selected Software" OnClick="Button1_Click" />
                <hr />
Related examples