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
Charles BaldoSoftware DeveloperAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
burakiewiczConnect With a Mentor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.