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?
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;
To find the DIV in the code behind, you'll need to add the runat="server"
tag to the DIV.
If you're going to do that, you might as well just use a Panel
, as it outputs a DIV anyway.
After doing the above, you should be able to find it like this:
Panel panel = (Panel)Repeater1.Items[0].FindControl("Panel1");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With