0

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.

3
Contributors
2
Replies
5
Views
6 Years
Discussion Span
Last Post by yorro
0

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,

0

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.
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.