Control not being found when looping through controls
I am looping through all the dynamic controls in a form, if the control ID begins with an 'o', I know it is a certain type of radiobutton, and I need to see if it is checked or not. But my code below gives me the error
What is wrong with my code below?
For each pageControl in pollForm.Controls
' If the control id begins with 'o' it is an optional radiobutton
If Mid(pageControl.ID, 1, 1) = "o" Then
myControl = Page.FindControl(pageControl.ID) ' ...object reference not set to an instance of an object.
End If
If myControl.Checked Then
Response.Write("The control was checked")
End If
Next