title: Access EditItemTemplate from CodeBehind
body: <p>I have problem dealing with EditItemTemplate. </p>
  
  <p>What I am trying to do is to update my <code>TextBox txt_name</code> but I can't get what the user ingresses And I get the old value instead at the code-behind.</p>
  
  <p>Am I missing something?</p>
  
  <h1>FRONT CODE</h1>
  
  <pre><code>&lt;asp:GridView ID="GridView_account" runat="server" AutoGenerateColumns="false" ShowFooter="True"
      OnRowCancelingEdit="GridView_account_RowCancelingEdit" OnRowEditing="GridView_account_RowEditing"
      OnRowUpdating="GridView_account_RowUpdating" OnRowCommand="GridView_account_RowCommand"
      OnRowDeleting="GridView_account_RowDeleting" OnSelectedIndexChanged="GridView_account_SelectedIndexChanged"
      DataKeyNames="UID" Height="110px" Width="497px"&gt;
      &lt;Columns&gt;
          &lt;asp:TemplateField HeaderText="UID" SortExpression="UID"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:Label ID="label_accid" runat="server" Text='&lt;%# Bind("UID") %&gt;'&gt;&lt;/asp:Label&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
          &lt;asp:TemplateField HeaderText="User Name (required)" SortExpression="NyA"&gt;
              &lt;EditItemTemplate&gt;
                  &lt;asp:TextBox ID="txt_name" runat="server" Text='&lt;%# Bind("NyA") %&gt;'/&gt;
              &lt;/EditItemTemplate&gt;
              &lt;FooterTemplate&gt;
                  &lt;asp:TextBox ID="txt_newname" runat="server"&gt;&lt;/asp:TextBox&gt;
              &lt;/FooterTemplate&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:Label ID="label_name" runat="server" Text='&lt;%# Bind("NyA") %&gt;'&gt;&lt;/asp:Label&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
          &lt;asp:TemplateField HeaderText="Email Address (required)" SortExpression="eMail"&gt;
              &lt;EditItemTemplate&gt;
                  &lt;asp:TextBox ID="txt_email" runat="server" Text='&lt;%# Bind("eMail") %&gt;'&gt;&lt;/asp:TextBox&gt;
              &lt;/EditItemTemplate&gt;
              &lt;FooterTemplate&gt;
                  &lt;asp:TextBox ID="txt_newemail" runat="server"&gt;&lt;/asp:TextBox&gt;
              &lt;/FooterTemplate&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:Label ID="label_email" runat="server" Text='&lt;%# Bind("eMail") %&gt;'&gt;&lt;/asp:Label&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
          &lt;asp:TemplateField HeaderText="Options" ShowHeader="False"&gt;
              &lt;EditItemTemplate&gt;
                  &lt;asp:LinkButton ID="LinkButton_update" runat="server" CausesValidation="True" CommandName="Update"
                      Text="Update"&gt;&lt;/asp:LinkButton&gt;
                  &lt;asp:LinkButton ID="LinkButton_cancel" runat="server" CausesValidation="False" CommandName="Cancel"
                      Text="Cancel"&gt;&lt;/asp:LinkButton&gt;
                  &lt;asp:LinkButton ID="LinkButton_delete" runat="server" CausesValidation="False" CommandName="Delete"
                      Text="Delete"&gt;&lt;/asp:LinkButton&gt;
              &lt;/EditItemTemplate&gt;
              &lt;FooterTemplate&gt;
                  &lt;asp:LinkButton ID="LinkButton_addnew" runat="server" CausesValidation="False" CommandName="AddNew"
                      Text="Add New"&gt;&lt;/asp:LinkButton&gt;
              &lt;/FooterTemplate&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:LinkButton ID="LinkButton_edit" runat="server" CausesValidation="False" CommandName="Edit"
                      Text="Edit"&gt;&lt;/asp:LinkButton&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
          &lt;asp:TemplateField HeaderText="Manage Role" ShowHeader="False"&gt;
              &lt;ItemTemplate&gt;
                  &lt;asp:LinkButton ID="Selectbtn" runat="server" CausesValidation="False" CommandName="Select"
                      Text="Select"&gt;&lt;/asp:LinkButton&gt;
              &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
      &lt;/Columns&gt;
  &lt;/asp:GridView&gt;
  </code></pre>
  
  <h1>CODE BEHIND</h1>
  
  <pre><code>protected void GridView_account_RowUpdating(object sender, GridViewUpdateEventArgs e)
  {
      user u = Business.GetUser(((Label)GridView_account.Rows[e.RowIndex].FindControl("label_accid")).Text);
      //HERE'S MY PROBLEM!
      u.fullname = ((TextBox)GridView_account.Rows[e.RowIndex].FindControl("txt_name")).Text;
      //txt_name is returning the old value and not the one the user has input recently.
  
      Business.UpdateUser(u);
      GridView_account.EditIndex = -1;
      fillgridview();
  }//
  </code></pre>