title: Select All Items in asp.net CheckBoxList
body: <p>ASP.NET and C#.</p>
  
  <p>I'd like to have a CheckboxList with a "Select All" item.</p>
  
  <ul>
  <li>When this particular item is
  selected, all others will be selected
  too.   </li>
  <li>When selection is removed from
  this item, so too will it be from all
  others items. </li>
  <li>Checking/Unchecking of
  any other items will only have an
  effect on that particular item
  regardless of the selection state of
  "Select All" item.</li>
  </ul>
  
  <p>I am looking for a jquery solution to this.</p>
  
  <p>Here is the databinding code in my codebehind:</p>
  
  <pre><code>IList&lt;Central&gt; Centrals = new CentralProvider().GetAllCentralsAsList();
  Centrals.Insert(0, new Central(){Central_ID = 999, Central_Name = "Select All"});
  CentralChecks.DataSource = Centrals;
  CentralChecks.DataTextField = "Central_Name";
  CentralChecks.DataValueField = "Central_ID";
  CentralChecks.DataBind();
  </code></pre>
  
  <p>And here is the markup:</p>
  
  <pre><code>&lt;div class="CentralDiv" id="CentralDiv"&gt;
      &lt;h2&gt;Centrals:&lt;/h2&gt;
      &lt;span&gt;
          &lt;asp:TextBox ID="CentralTextBox" runat="server" CssClass="textbox"&gt;Centrals&lt;/asp:TextBox&gt;
          &lt;img id="CentralArrow" src="images/down_arrow.jpg" style="margin-left: -22px; margin-bottom: -5px" /&gt;
      &lt;/span&gt;
      &lt;div id="CentralEffect" class="ui-widget-content"&gt;
          &lt;asp:CheckBoxList ID="CentralChecks" runat="server" onclick="GetSelectedCentralValue();"&gt;
          &lt;/asp:CheckBoxList&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Note that there are multiple checkbox lists on the page, so any solution must keep this in mind.</p>