Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Ordering items in ListBox

Reply
Thread Tools

Ordering items in ListBox

 
 
=?Utf-8?B?RGlnZ2xlcg==?=
Guest
Posts: n/a
 
      05-04-2004
I have a group of items in the database that need to be sorted by the client. There is a field in the database that stores the desired order (0, 1, 2, etc...). I would like to allow the client to move the ListBox.Items up and down in the ListBox via JavaScript and then, on the form submit, read the items in the ListBox from the client IN ORDER so I can save the changes in position into the database.

Unfortunately, the server is unaware of the changes in the ListBox. While in the 'for' loop, it remembers from server memory the original order rather than actually read them from the client.

Is there any way to read the actual order of the items from the client?
 
Reply With Quote
 
 
 
 
Peter O'Reilly
Guest
Posts: n/a
 
      05-04-2004
The biggest task is reconstructing the list box from scratch each time the
user moves an item up or down using client side JavaScript. This is no small
order, but it is very possible to do.

Specifically, there is no index to adjust with the HTML select input list
box. You must dump the contents into an array, clear the list box and then
repopulate the list box with list items. Each listbox item has a value and
a display text property. Set the value property to the desired list order
index which will then be used by your server side executing code.

Remember it's HTML, it's light weight and following w3c specifications.
Unlike say a rich client windows forms application, much of the creative
coding is left up to you -in this case an HTML select input. Good luck.
--
Peter O'Reilly


 
Reply With Quote
 
 
 
 
=?Utf-8?B?QmluIFNvbmcsIE1DUA==?=
Guest
Posts: n/a
 
      05-04-2004
Hi

ListBox is only supposed submit selection to server not the order. You might need to add a hidden field(runat server) and store the client changed order like "3,2,4,1". Then you can handle it on server

Bin Song, MCP
 
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
Z-Ordering (Morton ordering) question nbigaouette C Programming 2 11-06-2009 05:26 AM
copy ListBox items to anoher listbox Tomas ASP .Net 1 08-12-2008 08:22 AM
Listbox move multiple selected items to second listbox K B ASP .Net 2 01-08-2007 11:16 AM
re-ordering ListBox items Stimp ASP .Net 3 11-19-2004 01:30 PM
How do I move all items in a listbox to another listbox kent ASP .Net 1 05-03-2004 12:17 AM



Advertisments