Moving listbox items from one to another

B

Brian Simmons

Hi All,

I search on codeproject and google but didn't find what I was looking for.

Anybody know of a good implementation where you have 2 listboxes and you
want to move items between the 2.

I.e.
[Available Items] << < > >> [Select Items]

< > symbols are buttons where:
<< = Move all from righthand side to lefthand side
< = Move the selected item from righthand side to lefthand side
= Move the selected item from lefthand side to righthand side

Thanks,
Brian
 
B

bruce barker

if you want any performance then this must be done in javascript. any
good javascript book should have an example.

hint: as select only post back the selected values, sote the selected
item values in a hidden field (or mark itemes selected in the onsubmit
event).

-- bruce (sqlwork.com)

Brian said:
Hi All,

I search on codeproject and google but didn't find what I was looking for.

Anybody know of a good implementation where you have 2 listboxes and you
want to move items between the 2.

I.e.
[Available Items] << < > >> [Select Items]

< > symbols are buttons where:
<< = Move all from righthand side to lefthand side
< = Move the selected item from righthand side to lefthand side
= Move the selected item from lefthand side to righthand side

Thanks,
Brian
 
S

Steven Cheng[MSFT]

Hi Brian,

For moving or copy items between ASP.NET (or standard html) listbox, there
are two approahes:

** using server-side code to perform the move or copy during postback
event, this will cause multiple postback when you frequently perform the
oepration, but the advantage is that postback can help automatically
maintain the viewstate for control.

** using client-side script to modify the listbox and copy items. This can
avoid postback and give better user experience, but you need to record the
changes at client-side and persist the changes when postback to
server-side(if the page will go across multiple postback during the listbox
items movement)

Here are some web articles which have provided some implementation through
client-side script approach and some has even encapsulated the function
into a custom webcontrol:

#PickList
http://www.codeproject.com/aspnet/DblPanePickList.asp

#How To Move Items Between Lists with JavaScript
http://www.devx.com/getHelpOn/10MinuteSolution/16372/1954?pf=true

#Move Items Between 2 ListBoxes
http://weblogs.asp.net/coltk/archive/2005/06/15/412657.aspx

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.
 

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,982
Messages
2,570,185
Members
46,738
Latest member
JinaMacvit

Latest Threads

Top