Last active
September 27, 2015 11:18
-
-
Save dannylloyd/1261600 to your computer and use it in GitHub Desktop.
Selects all checkboxes in a asp.net gridview
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var gridView = '#<%= gridViewId.ClientID%>'; | |
| var checkAll = '#checkBoxId'; | |
| $(checkAll).click(function (i, v) { | |
| $('input[type=checkbox]', gridView).prop('checked', this.checked); | |
| }); | |
| var checkCount = $('input[type=checkbox]', gridView).length; | |
| $('input[type=checkbox]', gridView).click(function (i, v) { | |
| $(checkAll).prop('checked', $('input:checked', gridView).length == checkCount); | |
| }); |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Revised the original one, this will select and deselect all checkboxes. If one of the gridview checkboxes is unchecked the select all will deselect itself.