Results 1 to 2 of 2

Thread: Control not being found when looping through controls

  1. #1

    Thread Starter
    Hyperactive Member greg_quinn's Avatar
    Join Date
    Nov 2002
    Location
    South Africa
    Posts
    366

    Unhappy 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

  2. #2
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    A simpler way may be to just add an Attribute to the control after you create it, and search for the existence of that attribute.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width