Vinz' Blog

"Code, Beer and Music" ~ my way of being a programmer!
posts - 124, comments - 366, trackbacks - 0

My Links

News

Archives

Image Galleries

Accessing Controls in GridView TemplateFields on GridView Edit Mode

This example demonstrates on 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 demo:

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

      }

   }

}

 

Print | posted on Tuesday, February 17, 2009 5:35 PM |

Feedback

Gravatar

# re: Accessing Controls in GridView TemplateFields on GridView Edit Mode

Very good
5/4/2009 8:35 PM | Nermin
Gravatar

# Accessing Controls in GridView TemplateFields on GridView Edit Mode

Thanx! :)
6/18/2009 2:17 AM | Amit Patil
Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 
 

Powered by: