473,382 Members | 1,809 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,382 software developers and data experts.

Displaying selected items at the top of the listbox

Displaying selected items at the top of the listbox

Hi,
I am having two listboxes - one with ids and second with the related names.
When user selects an item in one listbox, the corresponding item will be
selected in the second listbox too. The problem is, when the user selects an
item and it is in the middle of the list, the user is not able to know
whether it is selected or not. Is there a way to display all the selected
items (multiple selection is allowed) at the top of the listboxes? I am using
datasource to bind the data to the listboxes.
Thanks!!!!!!!!!
Mar 9 '06 #1
2 2681
Untested, but this should be the right direction:

For Each Thing as ListItem In ListOfThings.Items
If Thing.Selected Then
ListOfThings.Items.Insert(0, Thing)
End If
Next

Note that databinding and postbacks may affect how this is executed, so pay
attention to your page events. Also I'm not 100% sure offhand whether this
will create a new ListItem object and leave the other behind, or if it will
rearrange like you need (I think it will rearrange it).

"Srimadhi" <Sr******@discussions.microsoft.com> wrote in message
news:9A**********************************@microsof t.com...
Displaying selected items at the top of the listbox

Hi,
I am having two listboxes - one with ids and second with the related
names.
When user selects an item in one listbox, the corresponding item will be
selected in the second listbox too. The problem is, when the user selects
an
item and it is in the middle of the list, the user is not able to know
whether it is selected or not. Is there a way to display all the selected
items (multiple selection is allowed) at the top of the listboxes? I am
using
datasource to bind the data to the listboxes.
Thanks!!!!!!!!!

Mar 9 '06 #2
'find the selected item in the second List
Dim LItem As ListItem = secondList.Items.FindByValue(ID)
If LItem Is Nothing Then
'add it at the very top
secondList.Items.Insert(0, New ListItem(LItem.Value, LItem.Text))
'remove the found item
secondList.Items.Remove(LItem)
End If
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"Srimadhi" wrote:
Displaying selected items at the top of the listbox

Hi,
I am having two listboxes - one with ids and second with the related names.
When user selects an item in one listbox, the corresponding item will be
selected in the second listbox too. The problem is, when the user selects an
item and it is in the middle of the list, the user is not able to know
whether it is selected or not. Is there a way to display all the selected
items (multiple selection is allowed) at the top of the listboxes? I am using
datasource to bind the data to the listboxes.
Thanks!!!!!!!!!

Mar 9 '06 #3

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

Similar topics

4
by: Peter Moscatt | last post by:
I am having trouble understanding the methods for the Listbox from Tk. If I was to select at item in the list using a mouse click (have already created the bind event) - what method returns the...
2
by: Fieldmedic | last post by:
I'm attempting to get an arraylist to display in a Listbox (listbox2). The arraylist is created from selections in a different listbox (listbox1). The 1st listbox has a selection mode of...
8
by: Vipin Kedia | last post by:
Hi I have written a code for showing the list boxes as selected using a Listitem and the selected property of the items. Now I have 2 list boxes in my page. But it shows only the selected values...
2
by: JP | last post by:
Hi, I am trying to loop through the listbox and read the selected items from the list, within a CLICK event on an aspx page. The following is what I have tried. It loops through the listbox,...
1
by: tshad | last post by:
I have a dropdown list set up to show 4 items on screen. If you select an item below that 4, it will not display on the screen (but it is selected). When you postback the list shows the first...
1
by: Ddraig | last post by:
Howdy, I've got a little project going and I am trying to figure out a good way to do this. But since I'm still learning I'm probably missing a few obvious steps. Also not sure if I have my...
2
by: John | last post by:
I have a listbox that is databound when my form loads. A user can then select and option using a drop down box. When the user selects an option the corresponding items in the listbox gets selected....
4
by: rn5a | last post by:
I am binding a DropDownList with records existing in a database table. I want to add an extra item *SELECT COMPANY* at index 0 so that by default, it gets selected. This is how I tried it but the...
2
by: aiswarya | last post by:
I've a table named student in my database.In it there are 7 columns .Now, in my form, when I click my table name, the name of columns should be displayed in one listbox ie in listbox1. Again, when...
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: 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:
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: 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: 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.