473,378 Members | 1,592 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.

Listbox move multiple selected items to second listbox

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

*** Sent via Developersdex http://www.developersdex.com ***
Jan 7 '07 #1
2 7204
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" <ka**********@comcast.netwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
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 ***

Jan 8 '07 #2
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

*** Sent via Developersdex http://www.developersdex.com ***
Jan 8 '07 #3

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

Similar topics

0
by: AK | last post by:
Hello, Listbox mulitselect property is set to true (extended). I am trying to implement drag and drop feature for a listbox. The drag & drop is done in the mouse move event (DoDragdrop...
1
by: Edward | last post by:
I am having a terrible time getting anything useful out of a listbox on my web form. I am populating it with the results from Postcode lookup software, and it is showing the results fine. What...
6
by: Chris Leuty | last post by:
I am populating a multiselect Listbox from a dataset, with the content of the listbox filled by one table, and the selections determined from another table. So far, I have been keeping the dataset...
6
by: Janaka | last post by:
Help! I have two ListBox controls on my web form. The first one gets populated on entry with values from the DB. I then use JavaScript to copy options from this ListBox to my second one. (I...
1
by: JMann101 | last post by:
I am writing a ASP.NET(VB) application and am having some trouble. I have a datagrid which list users and when an admin clicks "edit" a defined column becomes visible and a dynamic listbox control...
2
by: tangokilo | last post by:
Hello and thanks for your help, I have the following Listbox created in VisualStudio 2003 designer, desiring to select multiple entries from that list: -------------------------------...
3
by: Michael Meckelein | last post by:
Hello, I run into trouble move down a selected item in a listbox. The code moving down the item is the following one: for (int j = lv.SelectedItems.Count-1; j >=0; j--) { ListViewItem...
4
by: bogdan | last post by:
Hi, I have two listboxes on a page and need to move items between them - using buttons (e.g. "<<" ">>"). Can this be done on a client side in asp.net? I'd like to avoid hitting the server on...
1
by: divya | last post by:
Hello, I used the below code to move selected items between two listboxes Left and Right:- <%@ Page Language="C#" AutoEventWireup="true" CodeFile="TestPopup.aspx.cs" Inherits="TestPopup" %> ...
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.