Geeks With Blogs

News

Microsoft MVP


DZone MVB


Moderator at CodeASP.NET


Quiz Master







free counters
Free counters
Added on January 19,2012


Follow Me @vmsdurano

A bit About Me



Disclaimer
The opinions expressed herein are my own personal opinions and does not represent the opinions of my employers. Nor does it represent the opinion of my dog, because I don’t have one.


Vinz' Blog (ProudMonkey) "Code, Beer and Music ~ my way of being a programmer"

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: ,
Posted on Tuesday, February 17, 2009 5:35 PM ASP.NET , GridView | Back to top


Comments on this post: Accessing Controls in GridView TemplateFields on GridView Edit Mode

# re: Accessing Controls in GridView TemplateFields on GridView Edit Mode
Requesting Gravatar...
Very good
Left by Nermin on May 04, 2009 8:35 PM

# Accessing Controls in GridView TemplateFields on GridView Edit Mode
Requesting Gravatar...
Thanx! :)
Left by Amit Patil on Jun 18, 2009 2:17 AM

# re: Accessing Controls in GridView TemplateFields on GridView Edit Mode
Requesting Gravatar...
GREAT, Many thanks :)
Left by namnt on Nov 26, 2009 4:48 PM

# re: Accessing Controls in GridView TemplateFields on GridView Edit Mode
Requesting Gravatar...
I must say THANKS, I tried every thing but PreRender
Left by Oscar on May 31, 2011 11:15 PM

# re: Accessing Controls in GridView TemplateFields on GridView Edit Mode
Requesting Gravatar...
oooooooppppssss
i love you
as a world thanks for you , i need that and search evrywhere
nice
Left by bahador on Jul 20, 2011 1:50 AM

# re: Accessing Controls in GridView TemplateFields on GridView Edit Mode
Requesting Gravatar...
sir i just want the that i add the textbox at run time and how can i access that textbox
Left by lalit sharma on Oct 16, 2011 11:45 PM

# re: Accessing Controls in GridView TemplateFields on GridView Edit Mode
Requesting Gravatar...
sir i just want the that i add the textbox at run time and how can i access that textbox

and i want that a admin add dynamicaly
Left by lalit sharma on Oct 16, 2011 11:53 PM

comments powered by Disqus

Copyright © Vincent Maverick Durano | Powered by: GeeksWithBlogs.net