listbox woes

G

Guest

hey all,

i have a listbox on my .aspx page and when i highlight an item in the
listbox should i just be able to loop thru the items collection of the
listbox and delete what is selected? it's not letting me do that for some
reason i keep getting an error saying:
Collection was modified; enumeration operation may not execute.

what's the best way to do the delete?

thanks,
rodchar
 
G

Guest

You can't delete items from the collection that you are looping through.
Get the collection of selected items and use the ToArray method to get
them in an array. Loop through the array and remove each item from the
collection.
 
G

Guest

thank you.


Göran Andersson said:
You can't delete items from the collection that you are looping through.
Get the collection of selected items and use the ToArray method to get
them in an array. Loop through the array and remove each item from the
collection.
 

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

Members online

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top