title: jquery asp.net checkboxlist get item value
body: <p>I am trying to get the values from checkboxlist in jquery and depending from which value there is, make the checkbox checked or unchecked. 
  This is what I have:</p>
  
  <blockquote>
  <pre><code>  &lt;asp:CheckBoxList CssClass="styled" ID="chkTestTypeEdit" RepeatDirection="Horizontal" style="padding:5px;" runat="server"&gt;
         &lt;asp:ListItem Value="1" Text="Y/N" /&gt;
         &lt;asp:ListItem Value="2" Text="Num" /&gt;
    &lt;/asp:CheckBoxList&gt;
  </code></pre>
  </blockquote>
  
  <p>Then before modal popup is open I have this piece of code:</p>
  
  <pre><code>$(document).on("click", ".open-EditTest", function () {                 
      var optesttype =$(this).data('optesttype');                
      var items = $('#&lt;% = chkTestTypeEdit.ClientID %&gt; input:checkbox');
      for (var i = 0; i &lt; items.length; i++) {
  
          var val = $('#ctl00_MainContent_chkTestTypeEdit_0').val();
          var val2 = $('label[for=" + &lt;%= chkTestTypeEdit.ClientID %&gt; +_0 "]').text();
          if (items[i].value == optesttype) {
              items[i].checked = true;
              break;
          }
      }
      $('#EditTest').modal('show');
  });
  </code></pre>
  
  <p>So the optesttype will have either 1 or 2, and then I am trying to compare that agains the item[i] value but that value is always 'on'. 
  I tried two methods I found on the net with var val and val2, but nothing gets selected. 
  How do you guys think I need to approach this?
  Thanks, Laziale</p>