title: how to update a row through a row button click
body: <p>i have a button in my gridview with the ID "btnApprove". what i want is when the user clicks the button, the row "Status" will be updated to 'Approved'. how can i acheive that? one row will only be updated when the button is clicked depending on the transaction number</p>
  
  <p>here is my aspx code.</p>
  
  <pre><code> &lt;asp:UpdatePanel ID="panel1" runat="server"&gt;
           &lt;ContentTemplate&gt;
      &lt;asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" DataKeyNames="TransactionID" OnRowDataBound="GridView1_OnRowDataBound" OnRowCommand="GridView1_RowCommand" CellPadding="4" AllowPaging="true" PageIndex="2" OnPageIndexChanging="GridView1_PageIndexChanging" HeaderStyle-BackColor ="CornflowerBlue" BorderWidth="1" BorderColor="Gray" Width="100%" CssClass=" table table-hover" &gt;
          &lt;Columns&gt;
              &lt;asp:TemplateField&gt;
                  &lt;HeaderTemplate&gt;
                      &lt;asp:CheckBox ID="chkHeader" runat="server" /&gt;
                  &lt;/HeaderTemplate&gt;
                  &lt;ItemTemplate&gt;
                      &lt;asp:CheckBox ID="chkSelect" runat="server"  /&gt;
                  &lt;/ItemTemplate&gt;
              &lt;/asp:TemplateField&gt;
              &lt;asp:TemplateField&gt;
                  &lt;ItemTemplate&gt;
                      &lt;img style="cursor:pointer" src ="../Images/Icons/plus2.png" /&gt;
                      &lt;asp:Panel ID ="pnlDetails" runat="server" Style="display: none"&gt;
                          &lt;asp:GridView ID="gvDet" runat="server" AutoGenerateColumns="false" CssClass="ChildGrid"&gt;
                              &lt;Columns&gt;
                                  &lt;%--&lt;asp:BoundField ItemStyle-Width="20px" DataField="ID" HeaderText="ID" /&gt;--%&gt;
                                  &lt;asp:BoundField ItemStyle-Width="200px" DataField="ItemType" HeaderText="Type" /&gt;
                                  &lt;asp:BoundField ItemStyle-Width="250px" DataField="ItemModel" HeaderText="Model" /&gt;
                                  &lt;asp:BoundField ItemStyle-Width="140px" DataField="ItemQuantity" HeaderText="Requested Quantity" /&gt;
                                  &lt;asp:BoundField ItemStyle-Width="80px" DataField="ItemUnit" HeaderText="Unit" /&gt;
                                  &lt;asp:BoundField ItemStyle-Width="100px" DataField="ItemDate" HeaderText="Date Needed" /&gt;
                                  &lt;asp:BoundField ItemStyle-Width="200px" DataField="ItemDesc" HeaderText="Description" /&gt;
                                  &lt;%--&lt;asp:BoundField ItemStyle-Width="80px" DataField="ItemStatus" HeaderText="Status" /&gt;--%&gt;
                              &lt;/Columns&gt;
                          &lt;/asp:GridView&gt;
                      &lt;/asp:Panel&gt;
                  &lt;/ItemTemplate&gt;
              &lt;/asp:TemplateField&gt;
              &lt;asp:BoundField ItemStyle-Width="150px" DataField="TransactionID" HeaderText="Transaction Number" /&gt;
              &lt;asp:BoundField ItemStyle-Width="150px" DataField="DateFiled" HeaderText ="Date Filed" /&gt;
              &lt;asp:BoundField ItemStyle-Width="150px" DataField="ReqName" HeaderText="Name" /&gt;
              &lt;asp:BoundField ItemStyle-Width="150px" DataField="ReqCompany" HeaderText="Company" /&gt;
              &lt;asp:BoundField ItemStyle-Width="150px" DataField="ReqBranch" HeaderText="Branch" /&gt;
              &lt;asp:BoundField ItemStyle-Width="150px" DataField="ReqBU" HeaderText="Business Unit" /&gt;
              &lt;asp:BoundField ItemStyle-Width="150px" DataField="ReqDept" HeaderText="Department" /&gt;
              &lt;asp:BoundField ItemStyle-Width="150px" DataField="ReqSection" HeaderText="Section" /&gt;
              &lt;asp:BoundField ItemStyle-Width="150px" DataField="TransStatus" HeaderText="Status" /&gt;
              &lt;asp:TemplateField&gt;
                  &lt;ItemTemplate&gt;
                      &lt;asp:Button ID="btnApprove" runat="server" Text="Approve" OnClick="btnApprove_Click" CssClass="btn btn-primary" /&gt;
                  &lt;/ItemTemplate&gt;
              &lt;/asp:TemplateField&gt;
  
          &lt;/Columns&gt;
          &lt;HeaderStyle BackColor="CornflowerBlue" /&gt;
      &lt;/asp:GridView&gt;
               &lt;/ContentTemplate&gt;
           &lt;Triggers&gt;
               &lt;asp:AsyncPostBackTrigger ControlID="GridView1" /&gt;
           &lt;/Triggers&gt;
           &lt;/asp:UpdatePanel&gt;
  </code></pre>
  
  <hr>
  
  <p>Update here is my data source of my GridView</p>
  
  <pre><code> public void showTable()
      {
          Utility u = new Utility();
          string conn = u.connect();
          SqlConnection connUser = new SqlConnection(conn);
          SqlDataAdapter adp = new SqlDataAdapter("select * from MosefTransaction where TransStatus = 'Pending'", connUser);
          DataTable dt = new DataTable();
          connUser.Open();
          adp.Fill(dt);
          GridView1.DataSource = dt;
          GridView1.DataBind();
      }
  </code></pre>