title: Gridview get Checkbox.Checked value
body: <p>I have a GridView that has 10 columns populated by CheckBoxes. But instead of using <code>FindControl()</code> is there a way to get the <code>CheckBox.Checked</code> value by using a loop?</p>
  
  <p>Current Code:</p>
  
  <pre><code>if (e.CommandName == "updaterow")
  {
       int index = Convert.ToInt32(e.CommandArgument);
       GridViewRow selectedRow = GridView1.Rows[index];
       // TableCell BranchCode = selectedRow.Cells[0];
       CheckBox cb101 = (CheckBox)selectedRow.FindControl("cb101");
       CheckBox cb102 = (CheckBox)selectedRow.FindControl("cb102");
       //...and so on
  }  
  </code></pre>
  
  <p>ASPX CODE:</p>
  
  <pre><code>&lt;asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" OnRowCommand="GridView1_RowCommand"&gt;
      &lt;Columns&gt;
          &lt;asp:TemplateField HeaderText="101"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:CheckBox runat="server" id="cb101" AutoPostBack="false" Checked='&lt;%# Eval("101").ToString()=="1" ? true : false %&gt;' Enabled='&lt;%#(String.IsNullOrEmpty(Eval("101").ToString()) ? false: true) %&gt;'/&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
          ....and so on
          &lt;asp:ButtonField ButtonType="Button" CommandName="updaterow" Text="Update"/&gt;
      &lt;/Columns&gt;
  &lt;/asp:GridView&gt;
  </code></pre>