title: Get checkbox value in grid view instead of using foreach loop
body: <p>I am using foreach loop to get value of checkbox from a grid view and update the records by geting the current user <code>regID</code> on checkbox <code>CheckedChanged</code> event.</p>
  
  <p>In ASPX</p>
  
  <pre><code>   &lt;Columns&gt;
        &lt;asp:TemplateField &gt;
                              &lt;ItemTemplate&gt;
                                  &lt;asp:CheckBox ID="cbPaid" runat="server" AutoPostBack="true" OnCheckedChanged="cbPaid_CheckedChanged" Checked='&lt;%# bool.Parse(Eval("status").ToString() == "Paid" ? "True": "False") %&gt;' /&gt;
                              &lt;/ItemTemplate&gt;
                          &lt;/asp:TemplateField&gt;
                      &lt;/Columns&gt;
  </code></pre>
  
  <p>And in <code>aspx.cs</code></p>
  
  <pre><code>protected void cbPaid_CheckedChanged(object sender, EventArgs e)
  {
      foreach (GridViewRow row in GdParticipants.Rows)
      {
          CheckBox cbPaid = (CheckBox)row.FindControl("cbPaid");
  
          if (cbPaid!=null &amp;&amp; cbPaid.Checked == true)
          {
              string status = "Paid";
              int amount = Convert.ToInt32(ViewState["EventFee"]);
              DateTime date = DateTime.Now;
              string user = Session["user_id"].ToString();
              string regID = row.Cells[2].Text;
  
              string type = "Deposit";
              string account = "Participation";
              int balance = BAL.fetch_availableBalance();
              int total_balance = amount + balance;
              string detail = "Participant: "+regID+" fee has been Recieved";
              BAL.updateParticipants(regID, status, amount, user, date);
              BAL.saveBudgetTracking(type,account,amount,0,total_balance,detail,date);
  
          }
      }
      Response.Redirect("~/show_members.aspx");
  }
  </code></pre>
  
  <p>The problem with this approach is whenever a new user updated a new record by checking a check box it will loop through the whole records and update the current change all over the previous records. </p>
  
  <p>Anyone please guide me how can I get only the current regID from the row on which the checkbox was being checked and the checkbox value on <code>checkbox-CheckedChanged</code> event,  instead of a loop?</p>