asp.net - How to remove all item from a RadioButtonList

Remove all items from RadioButtonList
The following asp.net c# example code demonstrate us how can we remove all items from RadioButtonList server control's programmatically at run time. RadioButtonList is an asp.net list web server control. RadioButtonList allow web users to select only one item from the list at a time.

RadioButtonList control contains one or more ListItem objects. All ListItem objects exists in an items collection. So we can delete/remove RadioButtonList items by calling Collection<T> Class method. Collection Class Clear() method allow us to clear a RadioButtonList (remove all items from RadioButtonList). We can call the Clear() method as RadioButtonListID.Items.Clear().

This Clear() method remove/delete all items from RadioButtonList control at a time. Finally, the web browser display an empty RadioButtonList control.
RadioButtonListItemsClear.aspx

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

<!DOCTYPE html>

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

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>How to remove all item from RadioButtonList, items clear</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <h2 style="color:Navy">RadioButtonList: Items.Clear</h2>
        <asp:Label 
             ID="Label1"
             runat="server"
             Font-Bold="true"
             ForeColor="DeepSkyBlue"
             Text="asp.net controls"
             >
        </asp:Label>
        <asp:RadioButtonList 
             ID="RadioButtonList1"
             runat="server"
             BackColor="DeepSkyBlue"
             ForeColor="AliceBlue"
             >
             <asp:ListItem>CreateUserWizard</asp:ListItem>
             <asp:ListItem>LayoutEditorPart</asp:ListItem>
             <asp:ListItem>WebPartManager</asp:ListItem>
             <asp:ListItem>WebPartZone</asp:ListItem>
        </asp:RadioButtonList>
        <br /><br />
        <asp:Button 
             ID="Button1"
             runat="server"
             Font-Bold="true"
             ForeColor="DarkBlue"
             Text="Clear RadioButtonList Items"
             OnClick="Button1_Click"
             />
    </div>
    </form>
</body>
</html>
More asp.net examples