Having trouble with FindControl
Posted on 2010-11-16
I have an application where I need to perform operations on various controls throughout the page based on my repeater data. I need to populate Label Text, set Visible to true/false, etc.
The basic structure (framework) of my page is as such:
>> Label 1
>> Literal 1
>> Nested Repeater
>> >> Label 2
>> >> Hyperlink 2
>> >> >> Nested Nested Repeater
>> >> >> Hyperlink 3
>> >> >> END nested Repeater
>> END nested Repeater
I am having an impossible time knowing
(1) When to check for the control (i.e. what can I do during Page_Load, or DataBind, etc), and
(2) the syntax of the control (i.e. (Label)Page.FindControl("controName"); OR (Label)This.FindControl("controlName") OR (Label)e.Item.FindControl("controlName")
The error I keep getting is "Object reference not set to an instance of an object"
Can anyone clear this up for me?