GridView row in edit mode
<p>I posted similar question before, but I still have some problem with it. I use asp.net 4 and c#.</p>

<p>Please help me to understand I need to change the TEXT for the Label uxTest when a user click the EDIT button for a single row.</p>

<p>Any idea? thanks guys once again and sorry if looks like a duplicates question.</p>

<hr>

<pre><code>       &lt;%@ Page Language="C#" %&gt;
    &lt;%@ Import Namespace="System.Data" %&gt;

    &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

    &lt;script runat="server"&gt;

      protected void Page_Load(object sender, EventArgs e)
      {

        if (!Page.IsPostBack)
        {
          // Create a new table.
          DataTable taskTable = new DataTable("TaskList");

          // Create the columns.
          taskTable.Columns.Add("Id", typeof(int));
          taskTable.Columns.Add("Description", typeof(string));
          taskTable.Columns.Add("IsComplete", typeof(bool) );

          //Add data to the new table.
          for (int i = 0; i &lt; 20; i++)
          {
            DataRow tableRow = taskTable.NewRow();
            tableRow["Id"] = i;
            tableRow["Description"] = "Task " + i.ToString();
            tableRow["IsComplete"] = false;            
            taskTable.Rows.Add(tableRow);
          }

          //Persist the table in the Session object.
          Session["TaskTable"] = taskTable;

          //Bind data to the GridView control.
          BindData();
        }

      }

      protected void TaskGridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
      {
        TaskGridView.PageIndex = e.NewPageIndex;
        //Bind data to the GridView control.
        BindData();
      }

      protected void TaskGridView_RowEditing(object sender, GridViewEditEventArgs e)
      {
        //Set the edit index.
        TaskGridView.EditIndex = e.NewEditIndex;
        //Bind data to the GridView control.
        BindData();
      }

      protected void TaskGridView_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
      {
        //Reset the edit index.
        TaskGridView.EditIndex = -1;
        //Bind data to the GridView control.
        BindData();
      }

      protected void TaskGridView_RowUpdating(object sender, GridViewUpdateEventArgs e)
      {    
        //Retrieve the table from the session object.
        DataTable dt = (DataTable)Session["TaskTable"];

        //Update the values.
        GridViewRow row = TaskGridView.Rows[e.RowIndex];
        dt.Rows[row.DataItemIndex]["Id"] = ((TextBox)(row.Cells[1].Controls[0])).Text;
        dt.Rows[row.DataItemIndex]["Description"] = ((TextBox)(row.Cells[2].Controls[0])).Text;
        dt.Rows[row.DataItemIndex]["IsComplete"] = ((CheckBox)(row.Cells[3].Controls[0])).Checked;

        //Reset the edit index.
        TaskGridView.EditIndex = -1;

        //Bind data to the GridView control.
        BindData();
      }

      private void BindData()
      {
        TaskGridView.DataSource = Session["TaskTable"];
        TaskGridView.DataBind();
      }
    &lt;/script&gt;

    &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
    &lt;head id="Head1" runat="server"&gt;
        &lt;title&gt;GridView example&lt;/title&gt;
    &lt;/head&gt;
    &lt;body&gt;
        &lt;form id="form1" runat="server"&gt;
        &lt;div&gt;

          &lt;asp:GridView ID="TaskGridView" runat="server" 
            AutoGenerateEditButton="True" 
            AllowPaging="True"
            OnRowEditing="TaskGridView_RowEditing"         
            OnRowCancelingEdit="TaskGridView_RowCancelingEdit" 
            OnRowUpdating="TaskGridView_RowUpdating"
            OnPageIndexChanging="TaskGridView_PageIndexChanging" 
                AutoGenerateColumns="False"&gt;
              &lt;Columns&gt;
                  &lt;asp:TemplateField&gt;
                  &lt;EditItemTemplate&gt;
                      &lt;asp:Label ID="uxTest" runat="server" Text="TEST"&gt;&lt;/asp:Label&gt;
                  &lt;/EditItemTemplate&gt;
                  &lt;/asp:TemplateField&gt;
              &lt;/Columns&gt;
          &lt;/asp:GridView&gt;

        &lt;/div&gt;
        &lt;/form&gt;
    &lt;/body&gt;
    &lt;/html&gt;
</code></pre>

<hr>

<p>Code solutions:</p>

<pre><code>    if (e.Row.RowType == DataControlRowType.DataRow &amp;&amp;
                    (e.Row.RowState &amp; DataControlRowState.Edit) == DataControlRowState.Edit){
Label dl = (Label)e.Row.FindControl("uxLblTest");// Retrive control here
}
</code></pre>
