views:

174

answers:

1

I want to reference a table cell via it's string ID in my code like this FindControl("tdAnswer_a") because I am manipulating string ID names. The ASPX code looks like this :

<table>...<td ID="tdAnswer_a" runat="server" visible="true">

But FindControl is not able to find the table cell. When I reference it by ID like this : tdAnswer_a.Visible = true; in my codebehind, it has no problems. (This is not part of a repeater or gridview).

How can I FindControl my table cells via string ID names?

+3  A: 

FindControl is not a recursive function. If they are inside of some other container control, and you call FindControl on the Page object, then they won't be found.

You need to call FindControl on the direct container, or else write a recursive FindControl function.

You can see a version of a recursive FindControl in my old answer here.

womp
Thanks @womp! Unrelated, have you seen this? http://area51.stackexchange.com
rlb.usa