[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now


Quick way of displaying A-Z options in a DropDownList?

Posted on 2004-10-21
Medium Priority
Last Modified: 2008-03-04
Currently I have a DropDownList that displays the options A-Z as follows;

<asp:DropDownList runat="server" id="letterList" >
    <asp:ListItem value="a">A</asp:ListItem>
    <asp:ListItem value="b">B</asp:ListItem>
    <asp:ListItem value="z">Z</asp:ListItem>

Is there any way to achieve this quickly using some sort of looping functionality etc??
Question by:Rouchie
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
LVL 53

Assisted Solution

by:Ryan Chong
Ryan Chong earned 100 total points
ID: 12372369
try look for the DataSource property of the DropDownList , like:

In the Page_Load()

letterList.DataSource = myList

where myList is an array contains A to Z

hope this helps

Accepted Solution

mantarae earned 100 total points
ID: 12372432
declare a string array with the letters:
string[] letters = {"a", "b", "c", "d"}; //etc..

for (int i=0; i<letters.Length; i++){
    ListItem li = new ListItem(letters[i], letters[i]);
LVL 25

Author Comment

ID: 12372834
The main reason I asked was so that I didn't have to write out all the letters of the alphabet.  Both examples unfortuntely employ that method.  Is there no functionality in .NET to loop through letters like there are numbers??

Expert Comment

ID: 12372910
Nope, there isn't an automatic way to get a-z.

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

656 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