title: How to select or deselect all checkboxlist from other CheckBox control in form
body: <p>Problem inside case:</p>
  
  <ol>
  <li><p>If I select all, CheckBox controls:  it works according to logic</p></li>
  <li><p>If I deselect all CheckBox controls: It works according to logic. </p></li>
  <li><p>Problem: when user selects one by one checked box manually , when user check all options manually, below select all checked box will show as checked.</p></li>
  <li><p>Problem: user select all checkboxes in list and deselect any one option form a list,  below select all checked box button will unchecked</p></li>
  </ol>
  
  <p>Code:</p>
  
  <pre><code>if (checkBox1.Checked)
  {
      int length = chktb.Items.Count;
  
      for (int le = 0; le &lt; length; le++)
      {
  
          chktb.SetItemChecked(le, true);
      }
      checkBox1.Checked = true;
  
  }
  else 
  {
      int length = chktb.Items.Count;
  
      for (int le = 0; le &lt; length; le++)
      {
  
          chktb.SetItemChecked(le, false);
      }
  
      checkBox1.Checked = false;
  }
  </code></pre>
  
  <p><a href="http://i.stack.imgur.com/1eSVF.jpg" rel="nofollow">http://i.stack.imgur.com/1eSVF.jpg</a></p>