asp.net - How to get selected value from a RadioButtonList

RadioButtonList Selected Item Value
RadioButtonList is an asp.net list web server control that provides a single selection radio button group. the following asp.net c# example code demonstrate us how can we get selected item's value from a radiobuttonlist server control.

radiobuttonlist contains ListItem objects. ListItem object's Text property get or set the text displayed in web browser. and the Value property set the value associated with the ListItem.

radiobuttonlist SelectedItem property get the selected item from the list. so we can programmatically get the selected item's value in a radiobuttonlist control by accessing SelectedItem.Value property. because SelectedItem returns a ListItem object which is selected in radiobuttonlist server control.
radiobuttonlist-selectedvalue.aspx

<%@ Page Language="C#" AutoEventWireup="true"%>    
      
<!DOCTYPE html>
        
<script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    { 
        if(!Page.IsPostBack)
        {
            RadioButtonList1.Items.Add(new ListItem("Silver Oriole", "1"));
            RadioButtonList1.Items.Add(new ListItem("Hooded Oriole", "2"));
            RadioButtonList1.Items.Add(new ListItem("Orange Oriole", "3"));
            RadioButtonList1.Items.Add(new ListItem("Baltimore Oriole", "4"));
            RadioButtonList1.Items.Add(new ListItem("Streak-backed Oriole", "5"));
        }
    }

    protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        Label1.Text = "you selected....<br />";
        Label1.Text += "item: " + RadioButtonList1.SelectedItem.Text;
        Label1.Text += "<br />value: "+RadioButtonList1.SelectedItem.Value;
    }
</script>        
        
<html xmlns="http://www.w3.org/1999/xhtml">        
<head id="Head1" runat="server">        
    <title>asp.net radiobuttonlist selectedvalue</title>
</head>        
<body>        
    <form id="form1" runat="server">        
    <div>        
        <h2 style="color:MidnightBlue; font-style:italic;">        
            asp.net example - radiobuttonlist selectedvalue
        </h2>        
        <hr width="550" align="left" color="Gainsboro" />        
        <asp:Label       
            ID="Label1"       
            runat="server"      
            Text="select an item from radiobuttonlist...."
            Font-Size="Large"
            Width="350"
            >      
        </asp:Label>      
        <br /><br />
        <asp:RadioButtonList 
            ID="RadioButtonList1"
            runat="server"
            RepeatLayout="Table"
            RepeatColumns="2"
            AutoPostBack="true"
            OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged"
            >
        </asp:RadioButtonList>  
    </div>        
    </form>        
</body>        
</html>
More asp.net examples