Listbox move multiple selected items to second listbox

K

K B

Hi, The following code has been successful for me in the past and i just
can't figure out where I'm going wrong. When I debug I keep getting the
two top items as selected even though there are not selected and the
selected items are ignored. I'm using ASP.NET 2.0 and using two server
listbox controls. Any help appreciated.
Kit

Dim item As ListItem
Dim check As ListItem
For Each item In lstSelect.Items
If item.Selected = True Then
'check if value already exists in lstTo
check = lstTo.Items.FindByValue(item.Value)
If Not check Is Nothing Then
Exit Sub
Else
lstTo.Items.Add(New ListItem(item.Text, item.Value))
End If
End If
Next
 
A

Alvin Bruney [MVP]

Your code works just fine here. Maybe a reboot will do you some good.
 
K

K B

Thanks, Alvin. I'm embarrased to say after HOURs of looking at it, that
I realized my test database table had duplicate values...thereby
throwing of the selected items. I hope this posting helps someone else
some day.

thanks again,
kb
 

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,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top