asp.net - How to clear selection of a RadioButtonList

RadioButtonList ClearSelection() Method
The following asp.net c# example code demonstrate us how can we deselect/unchecked a RadioButtonList server controls programmatically at run time. RadioButtonList is an asp.net list web server control. RadioButtonList can contains one or more items.

Web users can select/checked only one item from RadioButtonList at a time. .Net RadioButtonList control render a Radio Group on web browser. So if we select an item from RadioButtonList control, then we cannot deselect the RadioButtonList control; but we can change the item selection.

Sometimes, .net developers want to provide the facility to their users to deselect a RadioButtonList control when users already selected an item. We can deselect/unchecked a RadioButtonList control's selection by calling its ClearSelection() method. When we call the ClearSelection() method, then the RadioButtonList goes to initial state and deselected.
RadioButtonListClearSelection.aspx

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

<!DOCTYPE html>

<script runat="server">
    protected void Button1_Click(object sender, System.EventArgs e)
    {
        RadioButtonList1.ClearSelection();
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>How to use RadioButtonList ClearSelection in asp.net</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:OliveDrab; font-style:italic;">
            How to use RadioButtonList
            <br /> ClearSelection in asp.net
        </h2>
        <hr width="350" align="left" color="Olive" />
        <asp:RadioButtonList
             ID="RadioButtonList1"
             runat="server"
             RepeatColumns="2"
             Font-Names="Ms Sans Serif"
             Font-Size="Large"
             >
            <asp:ListItem Text="LemonChiffon"></asp:ListItem>
            <asp:ListItem Text="LightGray" Selected="True"></asp:ListItem>
            <asp:ListItem Text="LightYellow"></asp:ListItem>
            <asp:ListItem Text="PaleTurquoise"></asp:ListItem>
            <asp:ListItem Text="PeachPuff"></asp:ListItem>
        </asp:RadioButtonList>
        <br />
        <asp:Button 
            ID="Button1"
            runat="server"
            OnClick="Button1_Click"
            Text="Clear Selection (Deselect RadioButtonList)"
            Height="45"
            Font-Bold="true"
            ForeColor="DodgerBlue"
            />
    </div>
    </form>
</body>
</html>
More asp.net examples