• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1619
  • Last Modified:

Get all values from dropdown list with c#


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

Any Help is appreciated
Charles Baldo
Charles Baldo
1 Solution
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
Rahul Goel ITILSenior Consultant - DeloitteCommented:

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

Open in new window

Charles BaldoSoftware DeveloperAuthor Commented:
Perfect, Thanks for the quick response

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now