Check all checkboxes in GridView using jQuery

GridView Id = gvUserInfo
CheckAll Box ID = chkHeader
Checkbox ID= chkChild


 <script src="scripts/jquery-1.3.2-jquery.min.js" type="text/javascript">
</script>
    <script src="scripts/jquery-1.7.2-jquery.min.js" type="text/javascript"></script>
   <script type="text/javascript">
       $(document).ready(function () {
           $("#gvUserInfo input[id*='chkHeader']").click(function () {
               $("#gvUserInfo input[id*='chkChild']").attr('checked', this.checked);
           });
           // if all checkbox are selected, check the selectall checkbox
           // and viceversa
           $("#gvUserInfo input[id*='chkChild']").click(function () {

               if ($("#gvUserInfo input[id*='chkChild']").length == $("#gvUserInfo input[id*='chkChild']:checked").length) {
                   $("#gvUserInfo input[id*='chkHeader']").attr("checked", "checked");
               } else {
                   $("#gvUserInfo input[id*='chkHeader']").removeAttr("checked");
               }
           });
       });
</script>

Do you want more TechChaitu Updates ?
Enter your email address:

Popular posts from this blog

Download Visakhapatnam Tirupati AC Double Decker Express Act