This example demonstrates how to access ASP.NET server controls that resides within the TemplateField Column of GridView on Edit Mode. In this example we are using the PreRender event of GridView instead of RowEditing event since we cannot directly access controls at RowEditing event of GridView.

See below for example:

protected void GridView1_PreRender(object sender, EventArgs e){
   if (this.GridView1.EditIndex != -1){
    Button b = GridView1.Rows[GridView1.EditIndex].FindControl("Button1") 
               as Button;
      if (b != null){
          //do something
      }
   }
}

I hope someone find this post useful! 

Technorati Tags: ,