Looping through controls in a FormView

Posted on 2006-05-08
Last Modified: 2012-05-05
I have a formview control on my page adn I need to loop through all of the label controls on it.  How can I accomplish this?  I keep getting an error stating that the formview has no enumeration type.

Thank you.
Question by:stankstank
    LVL 15

    Expert Comment

    what happens if you have:

    for each c as control in formview.Controls
    'do some debug output to verify it is looping


    does it output for each control?

    Author Comment

    I tried to loop through formview.controls, and for each control make a new label object.  The problem is, not all controls are labels - some are buttons.  It won't let me do foreach label, either.

    >> does it output for each control? <<
    I am not sure what you mean - can you re-ask the question?

    LVL 15

    Accepted Solution

    it will loop for every control, so you can put an if statement in there

    for each c as control in formview.Controls
       if typeof(c) is checkbox then
          'do something with checkbox c
       end if


    my question was just to get you to see if it was finding all the controls ok, say by writing the control name to the debug output - if the control names all appear in the debug output then it is finding the controls ok.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
    Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now