The first column in my gridview (gvAvailable) is a currently checkbox column ‘chkSelect’. The way it works now is that a user can check multiple checkboxes on a gridview, but I would like a jquery function to deselect all the checkboxes on the gridview except for the checkbox that was clicked.
I was also looking for a way to access the columns of the checked row with jquery on a button click.
Thanks for any help
Here’s how the generated html looks
<table class='Grid' cellspacing='0' border='0' id='gvAvailable' style='width:99%;border-collapse:collapse;'> <tr class='GridHeader'> <th scope='col'> </th><th scope='col'>Guid</th><th scope='col'>Id</th><th scope='col'>Name</th> <th scope='col'>Facility</th><th scope='col'>Room</th> </tr> <tr class='GridItem'> <td> <input id='gvAvailable_ctl02_chkSelect' type='checkbox' name='gvAvailable$ctl02$chkSelect' /> </td> <td>24</td> <td>000101020201</td> <td>Test</td> <td>Test Facility</td> <td> </td> </tr><tr class='GridAltItem'> <td> <input id='gvAvailable_ctl03_chkSelect' type='checkbox' name='gvAvailable$ctl03$chkSelect' /> </td> <td>25</td> <td>1001</td> <td>Test 2</td> <td>Test 3</td> <td> </td> </tr> </table>
if you add the same class to each of the checkboxes in the markup, you can retrieve an array of them by saying
This will give you back the array of objects. You can then call ‘each’ on the array and deselect them all.
Then add the above function call in the click handler for the each checkbox:
the code above should be set up to run on page load.