Solved

asp.net + Cycle through Dropdownlist

Posted on 2006-07-22
2
242 Views
Last Modified: 2006-11-18
I have 11 dropdownlist that are all populated with the same data, i want to loop through each one to populate instead of listing each one at a time.

they are simply named drp1 through drp11

i have a function to populate them and call it with

populateDropDown("drp1") i enter the dropdownlist and it populates, so instead of entering 11 lines of code is there a way to loop 1 to 11 and dynamically change the dropdownlist name to send to the function
0
Comment
Question by:dkilby
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 17160820
VB.NET example:

    For Index As Integer = 1 To 11
      Dim ddl As DropDownList = Me.FindControl("drp" & Index)
      ddl.DataSource = Me.DataSet1.Tables(0)
      ddl.DataBind()
    Next

Bob
0
 

Author Comment

by:dkilby
ID: 17160877
Great thanks just cut me code down a whole bunch of lines
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

738 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