I’m trying to use FindControl() to SET the values of some DropDownLists on a page.
for some reason, it appears that FindControl() is returning a copy of the control object as opposed to a reference, I was under the impression that this would not be the case due to the lack of a copy constructor for Controls?
<EDIT>
Ok, it apparears that it is not in fact returning a copy, it’s simply not letting me set the visibilty of a control, the other properties I’m setting work fine.
Does anyone have any insight as to why this might be the case?
I’ve tried setting it in quick-watch mode then looking at the value straight away, and that isn’t actually changing the value either!
</EDIT>
<EDIT> (two)
Ok, I’m doing this in Page_Load, and it’s not in a gridview (I like how you guys assumed that one cus I was using FindControl()).
I’m doing this as there is a set of operations I have to perform on a dynamic number of similarly named lists, and it’s MUCH better to do it in a loop than to hard code it.
</EDIT>
Can anyone help?
Cheers, Ed
Edit:
Whoa, wait… are you setting the Visible property to
truerather than false?In your comment, you mention it changes back instantly. The
Visibleproperty will evaluate tofalseif it’s parent is set to be invisible, no matter how often you tell it the value should betrue.