title: Getting textbox.text in gridview auto generated edit control
body: <p>Hi i am having a problem using the auto generated edit button in my gridview.</p>
  
  <p>i am trying to get the username from the edit text box and insert it to my database like so:</p>
  
  <pre><code>&lt;asp:TemplateField HeaderText="User Name"&gt;
  &lt;ItemTemplate&gt;
      &lt;asp:Label ID="UserNamelbl" runat="server" Text='&lt;%# Eval("Username") %&gt;'&gt;&lt;/asp:Label&gt;
  &lt;/ItemTemplate&gt;
  &lt;EditItemTemplate&gt;
  &lt;asp:TextBox ID="UserNameEdit" Width="100" Text='&lt;%# Eval("Username") %&gt;' Enabled="true" runat="server"&gt;&lt;/asp:TextBox&gt;&lt;/EditItemTemplate&gt;
  &lt;/asp:TemplateField&gt;
  </code></pre>
  
  <p>c# method that occurs on the update click.</p>
  
  <pre><code>    protected void UsersGridView_RowUpdating(object sender, GridViewUpdateEventArgs e)
  {     
  
      GridViewRow row = UsersGridview.Rows[e.RowIndex];
      Connect c = new Connect("EdenSiteDB.accdb");
      string updatesql = "UPDATE Users Set Username= '" + ((TextBox)row.FindControl("UserNameEdit")).Text + "' , Email= '" + ((TextBox)row.FindControl("EmailEdit")).Text + "' , Admin= " + (((CheckBox)row.FindControl("IsAdminBoxEdit")).Checked).ToString() + " WHERE UserID= " + Session["UserId"].ToString() + ";";
      OleDbCommand updatecmm = new OleDbCommand(updatesql);
      c.TakeAction(updatecmm);
  
      string usersql = "SELECT * FROM Users;";
      dt = c.MakeConnection(usersql, "Users");
      UsersGridview.EditIndex = -1;
      DataBind();
  }
  </code></pre>
  
  <p>While running this is the updatesql:</p>
  
  <pre><code>updatesql = "UPDATE Users Set Username= 'edmx0' , Email= 'edmx0.et@gmail.com' , Admin= True WHERE UserID= 17;"
  </code></pre>
  
  <p>these are the previouse values. not the new ones i just entered.</p>
  
  <p>but when i debug it, my sql keeps coming up with the initial username, and not the one i just entered.
  I assume it has something to do with my gridview binding at that moment but i don't know how to fix it.</p>
  
  <p>Any help would be appreciated!</p>