Solved

Get all values from dropdown list with c#

Posted on 2008-06-23
3
1,571 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
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

760 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

20 Experts available now in Live!

Get 1:1 Help Now