title: check/uncheck all checkbox of datalist on button click which is outside of datalist
body: <p>I hava a datalist in side that I have checkbox</p>
  
  <pre><code>&lt;asp:DataList ID="dlst1" runat="server" RepeatDirection="Horizontal" OnItemDataBound="dlst1_ItemDataBound" CaptionAlign="Left"&gt;
   &lt;ItemTemplate&gt;
         &lt;asp:ImageButton ID="btnImage" runat="server" /&gt;
  
          &lt;asp:Label ID="lbl" runat="server"/&gt;
  
         &lt;asp:CheckBox ID="Chkbox" runat="server"  TextAlign="Right" /&gt;
    &lt;/ItemTemplate&gt;
  &lt;/asp:DataList&gt;
  </code></pre>
  
  <p>I have 2 button</p>
  
  <p>
   </p>
  
  <p>I want to check all the check box when user click on Check All btn, and Uncheck All checkbox when user click on Uncheck All btn, I don't want any post back, how to do it in client side.</p>
  
  <p>I am trying</p>
  
  <pre><code> function CheckOrUncheckAll(isChecked) {
       var dataList = document.getElementById('&lt;%= DataList.ClientID %&gt;');
       for (var index = 0; index &lt; dataList.rows.length; index++) {
           for (var cIndex = 0; cIndex &lt; dataList.rows[index].cells.length; cIndex++) {
               dataList.rows[index].cells[cIndex].childNodes[3].checked = isChecked;
                              }
                      }
                      return false;
              }
  
      &lt;asp:Button ID="btnCheckAll" runat="server" Text="Check All" OnClientClick="return CheckOrUncheckAll(true)" /&gt;
      &lt;asp:Button ID="btnUnCheckAll" runat="server" Text="Uncheck All" OnClientClick="return CheckOrUncheckAll(false)" /&gt;
  </code></pre>
  
  <p>its working fine but I don't want to use childNodes[3], because in future in in datalist something got added then I need to change the index.. any jquery to change this function</p>