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

re-ordering ListBox items

I have a listbox of values that I populate from a database.

I want the user to be able to re-order the list
(by first selecting an item and then clicking 'up' or 'down' buttons)
and then save the list back to the database.

First of all, I implemented the re-ordering through client-side
javascript, which worked great (also it didn't require a postback every
time an item was re-ordered). For testing purposes, I'm outputting the
contents of the ListBox collection to a string before I start writing
back to the database...

To my disbelief, upon clicking the button to output the ListBox, it only
output the original order of Items (not the re-ordered version) and
reloaded the screen back to the original order.

Obviously this is because the ListBox collection is held in Viewstate
and the client-side changes are not overwriting these.

This leads to my first question: is there any way for the client-side
changes to be written to Viewstate (or written to the ListBox
collection)??

Second question:
Alternatively, I could create a comma-delimited string containing a list
of the item values in the new order.. but I've not idea how to send this
back to the server... any ideas?

Finally, as a last resort I've tried to do this using asp.net server
controls (using post-back to update the collection everytime an item is
moved). This is the least-desirable alternative, but leads to my third
question:
Is it possible to somehow change the order of items in the ListBox
collection? I've had no luck finding any links on google.

Any help on the above is much appreciated,
Peter
--

"I hear ma train a comin'
.... hear freedom comin"
Nov 18 '05 #1
3 6075
1. Sorry, don't know of one.

2. Try storing your string in a hidden field.

3. Agreed this would be an annoying solution for the user, but in a pinch
probably pretty easy: on the postback, take the value of selectedindex,
decide up/down based on the button, then swap text and value of the two
listitems affected, e.g. listbox.items(selectedindex).text =
listbox.items(selectedindex+1).text, etc.

hth,

Bill

"Stimp" wrote:
I have a listbox of values that I populate from a database.

I want the user to be able to re-order the list
(by first selecting an item and then clicking 'up' or 'down' buttons)
and then save the list back to the database.

First of all, I implemented the re-ordering through client-side
javascript, which worked great (also it didn't require a postback every
time an item was re-ordered). For testing purposes, I'm outputting the
contents of the ListBox collection to a string before I start writing
back to the database...

To my disbelief, upon clicking the button to output the ListBox, it only
output the original order of Items (not the re-ordered version) and
reloaded the screen back to the original order.

Obviously this is because the ListBox collection is held in Viewstate
and the client-side changes are not overwriting these.

This leads to my first question: is there any way for the client-side
changes to be written to Viewstate (or written to the ListBox
collection)??

Second question:
Alternatively, I could create a comma-delimited string containing a list
of the item values in the new order.. but I've not idea how to send this
back to the server... any ideas?

Finally, as a last resort I've tried to do this using asp.net server
controls (using post-back to update the collection everytime an item is
moved). This is the least-desirable alternative, but leads to my third
question:
Is it possible to somehow change the order of items in the ListBox
collection? I've had no luck finding any links on google.

Any help on the above is much appreciated,
Peter
--

"I hear ma train a comin'
.... hear freedom comin"

Nov 18 '05 #2
On Thu, 18 Nov 2004 Bill Borg <Bi******@discussions.microsoft.com> wrote:
1. Sorry, don't know of one.

This leads to my first question: is there any way for the client-side
changes to be written to Viewstate (or written to the ListBox
collection)??


What about using the IPostBackDataHandler interface?
Apparently this tests if the current state is different to that in
Viewstate and, if so, will update the ViewState accordingly..

reading about it now...

http://www.netomatix.com/updowncontrol.aspx

Anybody here used this interface, or even if it's right for what I'm
trying to do?

Thanks,
Peter
--

"I hear ma train a comin'
.... hear freedom comin"
Nov 18 '05 #3
On Fri, 19 Nov 2004 Stimp <re*@spumco.com> wrote:
On Thu, 18 Nov 2004 Bill Borg <Bi******@discussions.microsoft.com> wrote:
1. Sorry, don't know of one.

This leads to my first question: is there any way for the client-side
changes to be written to Viewstate (or written to the ListBox
collection)??


What about using the IPostBackDataHandler interface?
Apparently this tests if the current state is different to that in
Viewstate and, if so, will update the ViewState accordingly..

reading about it now...

http://www.netomatix.com/updowncontrol.aspx

Anybody here used this interface, or even if it's right for what I'm
trying to do?


I figured it out using a hidden field and Viewstate.

And no postback.. yay me :)

Thanks again for the help
--

"I hear ma train a comin'
.... hear freedom comin"
Nov 18 '05 #4

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

Similar topics

1
by: Nel | last post by:
I have a question related to the "security" issues posed by Globals ON. It is good programming technique IMO to initialise variables, even if it's just $foo = 0; $bar = ""; Surely it would...
4
by: Craig Bailey | last post by:
Anyone recommend a good script editor for Mac OS X? Just finished a 4-day PHP class in front of a Windows machine, and liked the editor we used. Don't recall the name, but it gave line numbers as...
1
by: Chris | last post by:
Sorry to post so much code all at once but I'm banging my head against the wall trying to get this to work! Does anyone have any idea where I'm going wrong? Thanks in advance and sorry again...
11
by: James | last post by:
My form and results are on one page. If I use : if ($Company) { $query = "Select Company, Contact From tblworking Where ID = $Company Order By Company ASC"; }
4
by: Alan Walkington | last post by:
Folks: How can I get an /exec'ed/ process to run in the background on an XP box? I have a monitor-like process which I am starting as 'exec("something.exe");' and, of course the exec function...
1
by: John Ryan | last post by:
What PHP code would I use to check if submitted sites to my directory actually exist?? I want to use something that can return the server code to me, ie HTTP 300 OK, or whatever. Can I do this with...
10
by: James | last post by:
What is the best method for creating a Web Page that uses both PHP and HTML ? <HTML> BLA BLA BLA BLA BLA
8
by: Beowulf | last post by:
Hi Guru's, I have a query regarding using PHP to maintain a user profiles list. I want to be able to have a form where users can fill in their profile info (Name, hobbies etc) and attach an...
1
by: joost | last post by:
Hello, I'm kind of new to mySQL but more used to Sybase/PHP What is illegal about this query or can i not use combined query's in mySQL? DELETE FROM manufacturers WHERE manufacturers_id ...
3
by: presspley | last post by:
I have bought the book on advanced dreamweaver and PHP recently. I have installed MySQL and PHP server but am getting an error on the $GET statement show below. It says there is a problem with...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

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.