Showing posts with label footertemplate. Show all posts
Showing posts with label footertemplate. Show all posts

Monday, August 17, 2009

accessing a control in a repeater's headertemplate or footertemplate

If you are trying to FindControl on the repeater's ItemDataBound or ItemCreated event it's pretty easy. However I needed to access a control from the repeater's PreRender event. This is when I discovered that "Only items bound to the data source are contained in the Items collection. The header, footer, and separator are not included in the collection." (from MSDN).

Therefore I had to use a line like this which apparently works because "all child controls must exist inside the Controls collection" ("In Search of ASP.NET Controls", from odetocode.com)


HtmlTableRow tr = (HtmlTableRow)rptIncomplForms.Controls[0].Controls[0].FindControl("trFoot");