title: Which checkbox in the CheckBoxList was just Checked (or Un-Checked)?
body: <p>I have this checkboxlist in the aspx file:</p>
  
  <blockquote>
  <pre><code>        &lt;asp:CheckBoxList ID="CBL_LOC" runat="server" RepeatDirection="Horizontal" 
              AutoPostBack="True" Font-Size="Small" Font-Names="Calibri"&gt;
          &lt;/asp:CheckBoxList&gt;
  </code></pre>
  </blockquote>
  
  <p>Items are added in the codebehind, based on user's previous input, like this:</p>
  
  <pre><code>    L = New ListItem
      L.Text = "ALL"
      L.Value = "ALL"
      L.Selected = True
      CBL_LOC.Items.Add(L)
  
      conn.ConnectionString = strConnString
      conn.Open()
      cmd = New SqlCommand(Sql, conn)
      dr = cmd.ExecuteReader
      While dr.Read
          L = New ListItem
          L.Text = dr(0)
          L.Value = dr(0)
          CBL_LOC.Items.Add(L)
          L.Selected = True
      End While
      dr.Close()
      cmd.Dispose()
      conn.Close()
  </code></pre>
  
  <p>Now, when the user checks (or unchecks) the "ALL" checkbox, I'm trying to check/uncheck all the items, using this code:</p>
  
  <pre><code>    Dim CBL As CheckBoxList = sender
  
      If (CBL.SelectedValue = "ALL") Then
          For Each I As ListItem In CBL_LOC.Items
              I.Selected = CBL.Items(0).Selected
          Next
      End If
  </code></pre>
  
  <p>This works fine when the ALL checkbox goes from unchecked to checked, the SelectedValue is "ALL".  But when "ALL" is unchecked, and user checks "ALL", the SelectedValue shows as the value of the first "checked" checkbox, not the "ALL" box.</p>
  
  <p>Am I missing something here?  Is there a different/better way to determine which checkbox in the checkboxlist was just checked or unchecked?</p>