Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Clear radio button selection

Posted on 2011-02-16
4
Medium Priority
?
689 Views
Last Modified: 2012-06-21
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.
0
Comment
Question by:minglelinch
  • 2
4 Comments
 
LVL 8

Expert Comment

by:TheMozz
ID: 34907334
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;
}
0
 
LVL 14

Expert Comment

by:systan
ID: 34907413
I see, there are compiled errors;
Try to check your spellings or Caps or maybe radio buttons has the same names.
0
 
LVL 20

Expert Comment

by:informaniac
ID: 34907435
I'm nt sure abt this but can u try chklst.SelectedIndex = -1;
0
 
LVL 20

Accepted Solution

by:
informaniac earned 2000 total points
ID: 34907530
I'm nt sure abt this but can u try chklst.SelectedIndex = -1;
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Loops Section Overview
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question