473,545 Members | 2,032 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2690
Untested, but this should be the right direction:

For Each Thing as ListItem In ListOfThings.It ems
If Thing.Selected Then
ListOfThings.It ems.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******@discu ssions.microsof t.com> wrote in message
news:9A******** *************** ***********@mic rosoft.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.Item s.FindByValue(I D)
If LItem Is Nothing Then
'add it at the very top
secondList.Item s.Insert(0, New ListItem(LItem. Value, LItem.Text))
'remove the found item
secondList.Item s.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
22599
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 text of the selected item ? Pete
2
4210
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 MultiExtended. Once the selection has been made in the 1st ListBox, the user clicks on a button to generate the arraylist using the values selected. Then...
8
2822
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 of the last list box in both the list boxes. If i reverse the calls to the filllistbox methods it shows the value selected for the 1st list box in...
2
19422
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, but none of the items' SELECTED property is TRUE while I have selected a few items. What am I missing? Dim strFunds As String
1
1189
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 four and you have to scrolldown to see the one you chose. Is there a way to have the dropdownlist show the one (or the first one) that is selected?...
1
1069
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 logic right or not. What I am trying to figure out is the process by which I pull the information. I'm trying to populate a list box with items where...
2
2750
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. How can I show those selected items at the top of my listbox. The issue is when the user selects an item and it is in the middle of the list, the...
4
6121
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 extra item just doesn't get added to the DropDownList: ============================================= <script runat="server"> Sub...
2
1174
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 I click one column name in listbox1,the corresponding attributes of that column should be displayed in listbox2. If the column selected is of...
0
7475
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7409
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7664
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7437
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7771
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
3465
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1900
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1023
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
720
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.