
8.01.2005
Access Controls in Repeater Header / Footer
Took me a bit to discover this by trial & error today. The controls (labels, text box, etc) that are in a Repeater header and footer template are not automagically bound to code-behind class member variables like regular page controls are.
Instead, you can "find" them at runtime like this (note: if you are data binding the repeater control, this must be AFTER call to DataBind).
Not sure about relying on the Controls[0] like above. In my case, the items laid out like this:
I suppose another way to handle all this would be to handle the ItemCreated or ItemDataBound events, where you'll get a call for the Header and Footer items.
Instead, you can "find" them at runtime like this (note: if you are data binding the repeater control, this must be AFTER call to DataBind).
Label lblErrorHead = repErrors.Controls[0].FindControl( "lblErrorHead" ) as Label;
Not sure about relying on the Controls[0] like above. In my case, the items laid out like this:
- HeaderItem (element 0)
- Item (element 1)
- FooterItem (element 2)
I suppose another way to handle all this would be to handle the ItemCreated or ItemDataBound events, where you'll get a call for the Header and Footer items.
Comments:
Post a Comment