I'm having trouble with finding a checkbox control on a page. I have a repeater that creates a list of items with checkboxes (so I can activate/deactivate them). The checkboxes are named as follows in the html source:
ctl00$ContentPlaceHolder1$ActivateLevelZero$rptItems$ct100$chkIsActive
ctl00$ContentPlaceHolder1$ActivateLevelZero$rptItems$ct101$chkIsActive
ctl00$ContentPlaceHolder1$ActivateLevelZero$rptItems$ct102$chkIsActive
etc...
When I try to access them in the button_click event, I have a counter variable that starts at 100 and increments each time through the loop (I'm looping through the item collection).
So I use the following code:
If Not (Request.Form(String.Format(_
"ctl00$ContentPlaceHolder1$ActivateLevelZero$rptItems$ct{0}$chkIsActive", count.ToString())) Is Nothing) Then
It never finds the controls this way. However, if I replace {0} with 100 or any other valid number so that the actual form element name is specified, it finds it just fine. Only when I try to do it dynamically.
If I write out the value from the String.Format, it is correct.
Anyone have an idea what's going on?