Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Listbox move multiple selected items to second listbox

Reply
Thread Tools

Listbox move multiple selected items to second listbox

 
 
K B
Guest
Posts: n/a
 
      01-07-2007
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



*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
 
 
 
Alvin Bruney [MVP]
Guest
Posts: n/a
 
      01-08-2007
Your code works just fine here. Maybe a reboot will do you some good.

--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
OWC Black book on Amazon and
www.lulu.com/owc

"K B" <(E-Mail Removed)> wrote in message
news:%23$(E-Mail Removed)...
> 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
>
>
>
> *** Sent via Developersdex http://www.developersdex.com ***



 
Reply With Quote
 
 
 
 
K B
Guest
Posts: n/a
 
      01-08-2007
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



*** Sent via Developersdex http://www.developersdex.com ***
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
DropDownList 2 always returns Selected = 0 for all items - even selected item Iain ASP .Net 3 12-11-2006 11:07 AM
ListBox Programaticly Set Multiple Items as Selected Jason L Lind ASP .Net Web Controls 0 04-11-2006 10:55 PM
Work with multiple selected items from a ListBox Ryan Ternier ASP .Net 0 10-27-2005 06:19 PM
How do I move all items in a listbox to another listbox kent ASP .Net 1 05-03-2004 12:17 AM
Remove multiple selected items listbox Adrian Forbes ASP General 0 08-07-2003 03:19 PM



Advertisments