Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
find html control in gridview rowcommand event in asp.net?

Thanks in advance,
Posted
Updated 10-May-17 5:04am
v2

Try this :

C#
HtmlGenericControl div = e.Row.FindControl("msgDiv") as HtmlGenericControl;
 
Share this answer
 
Comments
Mohamed Mitwalli 23-Apr-12 4:30am    
5
Try this:
C#
grdRow = (GridViewRow) e.CommandSource
TextBox txtAbc= (TextBox)grdRow.FindControl("txtAbc");


And have a look Here[^]
Find Control in gridview on RowCommand event in asp.net[^]
 
Share this answer
 
v2
Comments
P.Salini 23-Apr-12 3:26am    
my 5!
Prasad_Kulkarni 23-Apr-12 3:34am    
Thank You
jaspalsingh183 23-Apr-12 3:42am    
I am trying to fin HTML control but ur link find SERVER side control.
Sandeep Mewara 23-Apr-12 5:18am    
This is not an answer. I would like to tell that OP wants to find 'HTML Control'. Not a general server control.
See my answer.
see this

http://www.dotnetfunda.com/forums/thread4605-want-to-find-control-in-gridview-on-rowcommand-event-in-aspnet.aspx[^]

[EDIT]
The above link provides the way to access control in gridview in rowcommand event. To access Html controls place runat="server" property to html controls and use the same way to access those controls.
 
Share this answer
 
v2
Comments
Sandeep Mewara 23-Apr-12 5:18am    
This is not an answer. I would like to tell that OP wants to find 'HTML Control'. Not a general server control.
Prasad_Kulkarni 23-Apr-12 6:34am    
My +5!
P.Salini 23-Apr-12 6:35am    
Thanks Prasad
You cannot use FindControl on HTML controls as long as they are not running on server.

HTML controls are on client side by default and if you specify runat="server" to them, only then that control will be accessible on server side.

Thus,
HTML
// Not accessible on server side.
<input type="text" id="myData"></input>


ASP.NET
//Accessible on server side using FindControl.
<input type="text" id="myDataVisible" runat="server"></input>


If you want to access HTML Control, define runat="server" or else it is not possible.
 
Share this answer
 
Find Div tag inside Gridview

String bn = ((HtmlGenericControl)gr.FindControl("divId")).InnerText;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900