473,378 Members | 1,446 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

DropDownList to String ArrayList


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

Jun 2 '06 #1
2 4609
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
--
http://www.openmymind.net/
http://www.fuelindustries.com/
<da**********@newcross-nursing.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...

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

Jun 2 '06 #2
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

Karl Seguin [MVP] wrote:
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
--
http://www.openmymind.net/
http://www.fuelindustries.com/
<da**********@newcross-nursing.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...

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


Jun 5 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Krish | last post by:
I donot understand why it is this way. I have an arraylist. I understand I can get the count by arraylist.count in .net studio, intellisense also gives me arraylist.count.tostring()
9
by: ad | last post by:
I have a string like "1,2,2,3,3,3,4" I want to trim off the duplicate part, and make it to "1,2,3,4" How can I do?
10
by: chrisben | last post by:
Hi, Here is the scenario. I have a list of IDs and there are multiple threads trying to add/remove/read from this list. I can do in C# 1. create Hashtable hList = Hashtable.Synchronized(new...
3
by: alfredo17 | last post by:
Some can help me to extract String by String from ArrayList. I can add an String but now I would like to read item by item from an ArrayList. Thanks
2
by: suganya | last post by:
object SortedItems = new object; for (int i = 0; i < SortedItems.Length; i++) { SortedItems = DropDownList1.Items; } Array.Sort(SortedItems); DropDownList1.Items.Clear();...
4
by: Marek Zegarek | last post by:
Hello! I'm trying to write a simple sub, but somewhere I'm making a mistake..... Problem is somewhere in adding elements to arraylist or dictionary.... I need to add in Dictionary one string...
6
by: srinivaspnv21 | last post by:
hi, plz help me, i hav a problem in cascading two or more dropdownlists(like after selecting country in one dropdownlist, its corresponding states should display) without refreshing the whole page....
2
by: Assimalyst | last post by:
Hi I have a Dictionary<string, List<string>>, which i have successfully filled. My problem is I need to create a filter expression using all possible permutations of its contents. i.e. the...
2
by: YASIN786 | last post by:
hi all i am helping a friend to develop a java program to implement the following features but i cannot understand how to go about this problem. A text file contains a number of English...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.