Solved

asp.net + Cycle through Dropdownlist

Posted on 2006-07-22
2
212 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
Comment Utility
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
Comment Utility
Great thanks just cut me code down a whole bunch of lines
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

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 …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

762 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

11 Experts available now in Live!

Get 1:1 Help Now