title: how to edit and update row values in grid view?
body: <p>I have a gridview like this :</p>
  
  <pre><code>&lt;asp:GridView ID="gvProducts" runat="server" AutoGenerateEditButton="True" AutoGenerateColumns="False"
                  OnRowEditing="gvProducts_RowEditing" OnRowUpdating="gvProducts_RowUpdating" CellPadding="4"
                  ForeColor="#333333" GridLines="None"&gt;
                  &lt;RowStyle BackColor="#FFFBD6" ForeColor="#333333" /&gt;
                  &lt;Columns&gt;
                      &lt;asp:TemplateField&gt;
                          &lt;HeaderTemplate&gt;
                              &lt;asp:Label ID="lblPID" runat="server" Text="Product ID"&gt;&lt;/asp:Label&gt;
                          &lt;/HeaderTemplate&gt;
                          &lt;ItemTemplate&gt;
                              &lt;asp:Label ID="lblProdID" runat="server" Text='&lt;%#Eval("ProductID")%&gt;'&gt;&lt;/asp:Label&gt;
                          &lt;/ItemTemplate&gt;
                          &lt;EditItemTemplate&gt;
                              &lt;asp:TextBox ID="txtProdID" runat="server" Text='&lt;%#Eval("ProductID")%&gt;'&gt;&lt;/asp:TextBox&gt;
                          &lt;/EditItemTemplate&gt;
                      &lt;/asp:TemplateField&gt;
                      &lt;asp:TemplateField&gt;
                          &lt;HeaderTemplate&gt;
                              &lt;asp:Label ID="lblPName" runat="server" Text="Product Name"&gt;&lt;/asp:Label&gt;
                          &lt;/HeaderTemplate&gt;
                          &lt;ItemTemplate&gt;
                              &lt;asp:Label ID="lblProdName" runat="server" Text='&lt;%#Eval("ProductName")%&gt;'&gt;&lt;/asp:Label&gt;
                          &lt;/ItemTemplate&gt;
                          &lt;EditItemTemplate&gt;
                              &lt;asp:TextBox ID="txtProdName" runat="server" Text='&lt;%#Eval("ProductName")%&gt;'&gt;&lt;/asp:TextBox&gt;
                          &lt;/EditItemTemplate&gt;
                      &lt;/asp:TemplateField&gt;
                  &lt;/Columns&gt;
                  &lt;FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" /&gt;
                  &lt;PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" /&gt;
                  &lt;SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" /&gt;
                  &lt;HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" /&gt;
                  &lt;AlternatingRowStyle BackColor="White" /&gt;
              &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>and here is the code behind page</p>
  
  <pre><code>    protected void gvProducts_RowEditing(object sender, GridViewEditEventArgs e)
      {
          gvProducts.EditIndex = e.NewEditIndex;
      }
  
      protected void gvProducts_RowUpdating(object sender, GridViewUpdateEventArgs e)
      {
  
          int i = e.RowIndex;
          object control = gvProducts.Rows[i].FindControl("txtProdID");
          //i want to access the new value from the object "control" but i m getting the previous value only
      }
  </code></pre>