How can I get all the data in dropdownlist?

For specific data, I encode: Dropdownlist.selecteditem.text. But how can I get all the data?

Thanks in advance.

Recommended Answers

Hi,
Create a loop that runs through the dropdownlist items. Like so:

for(int i = 0; i < dropdownlist.items.count; i++) {
   // access each item and do something with it via 
   // dropdownlist.items[i].ToString() or whatever suits
}

Hope that helps,

Jump to Post

All 2 Replies

Hi,
Create a loop that runs through the dropdownlist items. Like so:

for(int i = 0; i < dropdownlist.items.count; i++) {
   // access each item and do something with it via 
   // dropdownlist.items[i].ToString() or whatever suits
}

Hope that helps,

If you are planning to put them to an array.

dropdownlist.Items.CopyTo(SomeArray,0)
' First argument, the array. Second is the index of the array.
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.