In this article I will explain how to check uncheck all (select unselect all) CheckBoxes in ASP.Net CheckBoxList control using jQuery.
The check uncheck all functionality will be done using an additional CheckBox that will act as Check All CheckBox for the ASP.Net CheckBoxList control.
 
 
HTML Markup
The HTML Markup consists of an ASP.Net CheckBox for uncheck all (select unselect all) functionality and an ASP.Net CheckBoxList control
<asp:CheckBox ID="chkAll" Text="Select All" runat="server" />
<asp:CheckBoxList ID="chkFruits" runat="server">
    <asp:ListItem Text="Mango" />
    <asp:ListItem Text="Apple" />
    <asp:ListItem Text="Banana" />
    <asp:ListItem Text="Pineapple" />
    <asp:ListItem Text="Guava" />
    <asp:ListItem Text="Grapes" />
    <asp:ListItem Text="Papaya" />
</asp:CheckBoxList>
 
 
Check Uncheck all CheckBox in ASP.Net CheckBoxList control using jQuery
In the below JavaScript code, I have specified two jQuery Click handlers, one for the Check All CheckBox while other for each CheckBox inside ASP.Net CheckBoxList.
Check All CheckBox Click event handler
When the Check All CheckBox is clicked, then based on whether it is Checked or Unchecked, the CheckBoxList CheckBoxes are Checked or Unchecked by adding or removing the checked attribute respectively.
CheckBoxList CheckBox Click event handler
When the any one of the CheckBoxList CheckBox is clicked, then it is verified that if all the CheckBoxList CheckBoxes are checked then the Check All CheckBox will be checked else unchecked by adding or removing the checked attribute respectively.
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript">
    $(function () {
        $("[id*=chkAll]").bind("click", function () {
            if ($(this).is(":checked")) {
                $("[id*=chkFruits] input").attr("checked", "checked");
            } else {
                $("[id*=chkFruits] input").removeAttr("checked");
            }
        });
        $("[id*=chkFruits] input").bind("click", function () {
            if ($("[id*=chkFruits] input:checked").length == $("[id*=chkFruits] input").length) {
                $("[id*=chkAll]").attr("checked", "checked");
            } else {
                $("[id*=chkAll]").removeAttr("checked");
            }
        });
    });
</script>
 
Check Uncheck all items in ASP.Net CheckBoxList using jQuery
 
Demo
 
Downloads