Solved

Adding static values to drop down list

Posted on 2007-04-11
2
289 Views
Last Modified: 2008-02-01
I need to add several static values to a drop down list in c#. e.g. 01, -12. I know I can achieve this through a "for loop", but I would like to use the actual values (maybe through some array of sorts?)
0
Comment
Question by:felkamau
  • 2
2 Comments
 
LVL 4

Expert Comment

by:CBeach1980
ID: 18893233
Create an ArrayList to store the values:
ArrayList values = new ArrayList();
values.add("val1");
values.add("val2");
values.add("val3");
etc...

for (int i=0; i < values.Count; i++)
   dropDownList.Items.Add(values[i].ToString());
0
 
LVL 4

Accepted Solution

by:
CBeach1980 earned 500 total points
ID: 18893246
Better yet...

Create an ArrayList to store the values:
ArrayList values = new ArrayList();
values.add("val1");
values.add("val2");
values.add("val3");
etc...

dropDownList.DataSource = values;
dropDownList.DataBind();
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Check my code out(2) 2 54
C# Error - Add Failed 12 78
WKHTMLTOPDF - --disable-smart-shrinking not working 10 37
compare between entities in entity framework 8 0
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

867 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

21 Experts available now in Live!

Get 1:1 Help Now