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
Solved

asp.net + Cycle through Dropdownlist

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

860 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