Link to home
Start Free TrialLog in
Avatar of minglelinch
minglelinch

asked on

Clear radio button selection

I have a Yes/No choice radio button defined -
            <td align="left" valign="top">        
                <asp:Panel ID="Panel4" GroupingText="Use other Choice:" Font-Size="Small" BorderColor="#F4FAFE" ForeColor="Black" runat="server" Width="180px">              
                   <asp:RadioButtonList ID="RadioOther" runat="server" Width="150px" RepeatDirection="Horizontal" onclick= "SelectOther()">                      
                        <asp:ListItem  Value="Yes">Yes</asp:ListItem>
                        <asp:ListItem  Value="No">No</asp:ListItem>
                   </asp:RadioButtonList>
                </asp:Panel>
             </td>  

Assume the user select a radio choice Yes, and the Reset button need to deselect any option in the radio group. In C#, I used -
        RadioOther.Checked = false  or  RadioOther.checked = false
to clear the selection, and it does not work. Actually I got compile error.

How can I clear the selection?  Thanks.
Avatar of TheMozz
TheMozz
Flag of United States of America image

One way is to iterate the list of items and set the selected property to false:

foreach(ListItem item in RadioOther.Items)
{
     item.Selected = false;
}
I see, there are compiled errors;
Try to check your spellings or Caps or maybe radio buttons has the same names.
Avatar of Obadiah Christopher
I'm nt sure abt this but can u try chklst.SelectedIndex = -1;
ASKER CERTIFIED SOLUTION
Avatar of Obadiah Christopher
Obadiah Christopher
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial