Solved

Adding static values to drop down list

Posted on 2007-04-11
2
296 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Name space syntax error 12 56
Coding C# in Linux 8 61
application restarter  - for an exe that hangs 9 25
Call windows 10 virtual keyboard from windows forms app 2 32
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

785 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