Try like this:
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
try
{
if (e.CommandName == "Edit")
{
ImageButton img = (ImageButton)e.CommandSource as ImageButton;
GridViewRow row = img.NamingContainer as GridViewRow;
TextBox2.Text = ((Label)row.FindControl("txtEditTimeDepart")).Text;
}
}
catch (Exception ex)
{
lblstatus.Text = "Error" + ex.ToString();
}
}