By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,720 Members | 2,095 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,720 IT Pros & Developers. It's quick & easy.

Ordering items in ListBox

P: n/a
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?
Nov 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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
Nov 18 '05 #2

P: n/a
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
Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.