Posts Tagged ‘clear’

How to Deselect All From a RadioButtonList in C#

Unlike a list of check boxes, a list of radio buttons is designed to allow users to select only one option. However, once an option is selected for a radio button, it is now more difficult to deselect all options. However, a C# function ClearSelection, will allow the selection to be cleared.

In our example below is a RadioButtonList called rblSelectAOption:

<asp:RadioButtonList ID="rblSelectAOption" runat="server">
<asp:ListItem>One</asp:ListItem>
<asp:ListItem>Two</asp:ListItem>
<asp:ListItem>Three</asp:ListItem>
</asp:RadioButtonList>

Next, the codebehind below will clear all selected option:

rblSelectAOption.ClearSelection();

That’s all it takes!