Click here to Skip to main content
14,699,886 members
Please Sign up or sign in to vote.
3.67/5 (2 votes)
See more:
i have a grid view and in a grid view i have a check box. i want when i select any check box then only that particular check box is select and last selected check box is unselect. i want this using java script on aspx page. please suggest me code
Posted

use templete column checkbox list for gridview column and try this...

// Convert chkDateRange CheckBoxList Cheked Event as  RadioButton Checked Event.
       function ConvertToRadio(event) {
           var chkBoxCount = document.getElementById('<%= chkDateRange.ClientID %>').getElementsByTagName("input");
           for (i = 0; i < chkBoxCount.length; i++) {
               if (chkBoxCount[i].type == 'checkbox')
                   chkBoxCount[i].checked = false;
           }
           if (event.target == null) {
               event.srcElement.checked = true;

           }
           else {
               event.target.checked = true;
           }
       }
   
Refer this link if your intention was to select only one Checkbox per Gridview Row.

applying-single-selection-to-the-checkbox-in-a-gridview[^]

Or refer this if , wanted to Select the Single CheckBox column out of Multiple CheckBox columns

Allow-to-user-to-check-only-one-checkbox-in-ASPNet-GridView-Row/[^]
   

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