Solved

Get all values from dropdown list with c#

Posted on 2008-06-23
3
1,580 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:charlesbaldo
3 Comments
 
LVL 16

Accepted Solution

by:
burakiewicz earned 500 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:charlesbaldo
ID: 31469856
Perfect, Thanks for the quick response
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

773 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