Click here to Skip to main content
15,924,317 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Iam using gridview for attendance purpose in that i have radiobutton for 31 columns . after radio button checked by click . then if i try to uncheck the corresponding radbtn it will not uncheck as checkbox. please help me with code

Thanks in advance
Posted
Updated 30-Oct-18 8:33am
Comments
pradiprenushe 6-Aug-14 3:18am    
You can use java script or jquery
Gihan Liyanage 6-Aug-14 4:16am    
Do you want to Unchecked the checked same radio button ?

XML
<html>
    <script type="text/javascript">
        var RadioBtn = document.getElementsByName('YourRadioButton');
        var booRadio;
        var x = 0;
         allRadios[x].onclick = function() {
                if(booRadio == this){
                    this.checked = false;
                    booRadio = null;
                }else{
                    booRadio = this;
                }
            };
    </script>
</html>



preform this javascript on radio button click
I didn't Try it but i hope it work...tell me what the result is
 
Share this answer
 
v2
As you may know setting the group name attribute of a radio button will not work if the radio button is located within a data representation control like a GridView. This is because the radio button inside a GridView behaves differently. Since a GridView is rendered as a table element, at run time it will assign a different "name" to each radio button. Hence you are able to select multiple rows.

Here's an article I that wrote a few years ago that covers the issue you are facing: Using Radio Button in GridView With JavaScript Validation[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900