asp.net: How to find repeater div in backend?

Steven Zack picture Steven Zack · Aug 24, 2011 · Viewed 12.7k times · Source

I use repeater to display records fetching from database, especially I use div tag to display html content stored in datatable. But I don't know how to find the div in backend. In Repeater_ItemDataBound event I can use

Control divControl=e.Item.FindControl("divControl"); 

to get it but it does not have innerHtml property to set html content. Does anyone know how to get it as a div control?

Answer

CD.. picture CD.. · Aug 24, 2011

HtmlGenericControl defines the methods, properties, and events for all HTML server control elements not represented by a specific .NET Framework class.

So if its a server control you can simply use:

HtmlGenericControl divControl = e.Item.FindControl("divControl") as HtmlGenericControl;