Dec 12, 2007 05:02 AM|sbyard|LINK
The rationale behind many Microsoft ASP.NET controls is sound, but at times their implementation is frustrating, and even using VS2008, old issues still exist
For example, using a repeater, it is possible find controls in a header during databinding by adding a listener to the ItemCreated or ItemDataBound events.
Once a repeater is bound, only the bound Items are easily accessible through the Items property. If you subsequently want to get to a control in a header (or footer), there is no obvious method.
If you perform a recursive search of the repeater and its controls, you will see that the control structure does contain the header. So, what's an easy way to find controls in the header?
What I do is add a static helper class to a web site that contains a recursive control finder. Now, you need to be aware that with repeated items, there will be the same named item within each repeated item (that is ID : client ID and Unique ID are managed
to be unique)
Since a header and footer only exists once, their controls are easier to find by name (assuming there is no control with that name elsewhere in the repeater control descendants).
Here is some code to find controls by name and type