Finding controls in the header and footer
This is such a pain in the ass it's not even funny. I need to keep a running total of rows in my repeater, and then put a subtotal column at the bottom. You can't do a normal FindControl on an item, and I saw weird stuff in the newsgroups about trying to pass a "ctrl1:lblName" to the FindControl, as well as using OnItemDataBound, which doesn't really work for what I want to do. So now, for posteriety, is the way to access a server-based control in the footer of a repeater (I'm assuming the same thing would work for headers):
Dim lblFooter As Label lblFooter = CType(rptSample.Controls(rptSample.Controls.Count - 1).FindControl("lblFooter"), Label) lblFooter.Text = "You found me!"
Sheesh.. what a hassle to figure that out.
*Update:* "David":http://bigbrit.blogspot.com/ asked in the comments if I asked the VB.Net Clippy for help. Yes, yes I did... and here's the response I got:
Thanks to Pat from the FeralMarketing dept. for the image.