Solved

asp.net + Cycle through Dropdownlist

Posted on 2006-07-22
2
249 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

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

631 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