Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Get all values from dropdown list with c#

Posted on 2008-06-23
3
Medium Priority
?
1,612 Views
Last Modified: 2011-10-03
Hello

I need to retrieve all the text and  values in a dropdownlist using c#

Any Help is appreciated
0
Comment
Question by:Charles Baldo
3 Comments
 
LVL 16

Accepted Solution

by:
burakiewicz earned 2000 total points
ID: 21848280
what do you need to store them as, you can loop through the collection
foreach (ListItem li in ddlItems.Items)
{
    string s =li.Text;
    string x=li.Value
}
0
 
LVL 9

Expert Comment

by:Rahul Goel ITIL
ID: 21848328

foreach (ListItem item in dropDown1.Items)
{
    Console.WriteLine(li.Text.ToString() + "," + li.Value.ToString());
}

Open in new window

0
 

Author Closing Comment

by:Charles Baldo
ID: 31469856
Perfect, Thanks for the quick response
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
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.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Loops Section Overview
Suggested Courses

916 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