Search code examples
asp.netfindcontrol

ASP.net - Adding a control in code, how do I get it via FindControl()?


I create a table in code, add rows and then cells to it. In each cell there is a checkbox which has an ID I set.

I add this table to an updatepanel, and later on I want to find out which checkboxes the user has checked/unchecked.

I don't know the best way, so what I did was create a button that checks. I kept a reference to the checkboxes, and tried changing the checkedvalue in code, but this did not update my webpage. I figure it loses the reference once it is added in code.

So I tried to use Page.FindControl and passed the original ID I gave it, but it doesn't find it. I am guessing this is because it puts a load of crap before the ID before adding it to the page...

So basically, what do I do to check the if the checkboxes I added have been altered or not? A CheckedChange event didn't work either.


Solution

  • You may have to use a recursive FindControl