Instance name question

Posted on 2005-04-28
Last Modified: 2010-04-07
I know what I want the end result to be, but I don't know how to explain it.

Basically I have 4 dropdownlists on my page and I'm trying to find to appropriate one to the number I give them.

They are named:

And I am going to have a loop and depending on where I am at in the count it will change that drop down. Like in the first loop I want to change categoryNo1, and in the 2nd loop I want to change categoryNo2, etc.

I'm sure you all know what I'm talking about, but I'm a simple java guy and don't know VB well enough.

Question by:abradley81
    LVL 23

    Accepted Solution

    Dim i As Integer
    Dim list As DropDownList
    For i = 1 To 4
          list = DirectCast(FindControl("categoryNo" & i),DropDownList)
    LVL 23

    Expert Comment

    that'll get u the dropdownlist control,
    LVL 23

    Expert Comment

    for(int i=0;i<4;i++)
          DropDownList list = FindControl("categoryNo" + (i + 1).ToString()) as DropDownList
          if (list != null)

    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

    Suggested Solutions

    This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
    I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    746 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

    15 Experts available now in Live!

    Get 1:1 Help Now