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

Get all values from dropdown list with c#

Hello

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

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

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

Open in new window

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

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