DropDownList to String ArrayList

D

dan_williams

Without having to loop through all my items in a dropdownlist, is there
an existing asp.net 1.1 function to populate a comma delimited string
with the values of my dropdownlist?

I'm sure it's staring me in the face and there must be an easier way to
do the following without having to loop through all the values.

Dim item, items
For Each item In dropDownList.Items
items = items & "," & item.value
Next

i.e. items = dropDownList.Items.toString() OR
dropDowList.Items.getValues()

thanks in advance for any suggestions

Dan
 
K

Karl Seguin [MVP]

You can copy it to an array of ListItems, but you'll still need to loop
through it to extract the values.

It's 4 very trivial lines of code. If you want it to be one, create a
function. In 2.0 an elegant way might be to use a closure, but you'll end up
with the same amount of code...

Also, consider turning on option explicit and using a string builder when
concatenating more than 5 strings together..

Karl
 
D

dan_williams

OK, thanks. I was sure there was a function to do it and it was sending
me crazy! It's like when you think you've left the gas on at home or
something, and you have that nagging feeling in the back of your mind
that you're not quite remembering something!

Cheers anyway, i'll just stick with a loop or create my own function if
i need to reuse it more regularly.

Dan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top