Click here to Skip to main content
15,913,610 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends,

I am using VS 2005,.net framework 2,asp.net,c#.net
I have a gridview which contains a checkbox in an template colum.
I want to check whether atmost one check box should be checked?
That mean when click on checkbox in another row, the previous selected check should be unchecked
Is it possible to do it in Javascipt?


George
Posted

1 solution

<pre lang="text">

You mean only one check box allowed to checked if so you can do it using JQuery in such a manner


#1:- In template Column write the checkbox ID like 
         <asp:checkbox id="chk_"+ID onclick="SelectOne(ID);">

ID will be  PK fields which you are getting from database 

 funtion SelectOne(Id){
  //find all the checkbox into the grid unchecked   
 $('input[id*="chk_"]').removeAttr("checked");
// then make checked what you have clicked 
 $("#chk_" + Id ).attr("checked", "checked"); 
}

TRY THIS WILL WORK IF ANY ISSUE WRITE ME 

THANKS
 
Share this answer
 
v3

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