HTML:
<form id="form1" runat="server">
<div>
<asp:CheckBox ID="cbSelectAll" OnCheckedChanged="SelectAll" AutoPostBack="true" runat="server" />
SELECT ALL/UNCHECKED ALL
<asp:CheckBoxList ID="chkDemo" runat="server">
<asp:ListItem>Mango</asp:ListItem>
<asp:ListItem>Banana</asp:ListItem>
<asp:ListItem>Mango</asp:ListItem>
<asp:ListItem>Banana</asp:ListItem>
<asp:ListItem>Mango</asp:ListItem>
<asp:ListItem>Banana</asp:ListItem>
</asp:CheckBoxList>
<asp:Button ID="btnSave" Text="SAVE" runat="server" />
</div>
</form>
C# :
protected void SelectAll(object sender, EventArgs args)
{
bool b = (sender as CheckBox).Checked;
for (int i = 0; i < chkDemo.Items.Count; i++)
{
chkDemo.Items[i].Selected = b;
}
}