Click here to Skip to main content
15,886,611 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am have td in repeater. i want show and hide it on condition

How to Find a html tag from the repeater in C#?

for find button in repeater we write this code

C#
Button btn=Repeater1.FindControl("Button1") as Button;


but for html a tag?

C#
----- atag=Repeater1.FindControl("id of a tag") as -------;



fill in the -------???????
Posted
Updated 30-Apr-14 2:10am
v2
Comments
Sampath Lokuge 30-Apr-14 8:35am    
Can you put the code snippet for your Repeater ?
PRAKASH9 1-May-14 2:46am    
HtmlAnchor anchor = (HtmlAnchor)e.Item.FindControl("id of anchor tag");
write in itemdatabound event.

foreach(RepeaterItem rpt in Repeater1.Items)
{
HtmlAnchor anchor = (HtmlAnchor)rpt.FindControl("id of anchor tag");
}
write this in button click event.

Hi behnam haji,
As you asked, what is the C# class for td tag of html?
So you can cast the td tag in C# by writing the code given below.

C#
System.Web.UI.HtmlControls.HtmlTableCell atag = rpt.FindControl("id of a tag") as System.Web.UI.HtmlControls.HtmlTableCell;


C#
// import namespace 
using System.Web.UI.HtmlControls;

// and 
HtmlTableCell atag = rpt.FindControl("id of a tag") as HtmlTableCell;



and you can also see more html control classes from HtmlControls namespace.
 
Share this answer
 
if in case of text box Repeater1.FindControl("id of a tag") as HTMLtextbox;
 
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