473,320 Members | 2,177 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,320 software developers and data experts.

moving items from one list box to another

Kay
Hello,

I have two list boxes on my form, one initially displays with items and the
other displays blank, by clicking a button, it is possible to move items
from one box to another and vice a versa, this works fine. I also have a
dropdown list on the page with autopost back = true, my problem is as
follows: when the user selects an option in the dropdown list the form is
posted back to the server and certain other processing happens, then when
the form redisplays, the items that had been moved between the list boxes
have disappeared. How do I maintain the listboxes on a redisplay?
I need to do an autopostback on the dropdown list. I also have a save button
on the form and I know when the user clicks this, I can retrieve the value
in the listbox by doing a Request.Form("listboxID") on the server, however
the dropdownlist text changed event will occur before the save button is
clicked.

Any idea how I might preserve the users selection in the listboxes when I
present the screen back to them after the dropdown list text changed event?

Any help appreciated.
Thanks,
Kay.

Nov 18 '05 #1
5 11415
The problem is that you're using all client-side JavaScript to move the
item. Since the ViewState is not changed, and no event is fired, the server
side knows nothing about it. You have to have some way of informing the
server that a change has been made, and what made it. This can be
accomplished by wiring up a server-side event handler to do a PostBack and
move the data on the server side, or by putting some kind of hidden form
field into your client side that holds the data about the transfer, so that
when the PostBack occurs, your code can update the server-side lists.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Kay" <ka********@proteus.ie> wrote in message
news:OD**************@tk2msftngp13.phx.gbl...
Hello,

I have two list boxes on my form, one initially displays with items and the other displays blank, by clicking a button, it is possible to move items
from one box to another and vice a versa, this works fine. I also have a
dropdown list on the page with autopost back = true, my problem is as
follows: when the user selects an option in the dropdown list the form is
posted back to the server and certain other processing happens, then when
the form redisplays, the items that had been moved between the list boxes
have disappeared. How do I maintain the listboxes on a redisplay?
I need to do an autopostback on the dropdown list. I also have a save button on the form and I know when the user clicks this, I can retrieve the value
in the listbox by doing a Request.Form("listboxID") on the server, however
the dropdownlist text changed event will occur before the save button is
clicked.

Any idea how I might preserve the users selection in the listboxes when I
present the screen back to them after the dropdown list text changed event?
Any help appreciated.
Thanks,
Kay.

Nov 18 '05 #2
Without knowing exactly how your code works, I only have a few simple
things to double check. First, are you writing any code in the Page_Load
method that would always overwrite the settings of your dropdown list?
Next, are you enabling the viewstate for each dropdown list?

Chris

--------------------
Reply-To: "Kay" <ka********@proteus.ie>
From: "Kay" <ka********@proteus.ie>
Subject: moving items from one list box to another
Date: Fri, 13 Feb 2004 15:08:15 -0000
Lines: 25
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <OD**************@tk2msftngp13.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: 62.17.23.97
Path: cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTN GP08.phx.gbl!tk2msftngp13.
phx.gblXref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.framework.aspnet:209871
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

Hello,

I have two list boxes on my form, one initially displays with items and the
other displays blank, by clicking a button, it is possible to move items
from one box to another and vice a versa, this works fine. I also have a
dropdown list on the page with autopost back = true, my problem is as
follows: when the user selects an option in the dropdown list the form is
posted back to the server and certain other processing happens, then when
the form redisplays, the items that had been moved between the list boxes
have disappeared. How do I maintain the listboxes on a redisplay?
I need to do an autopostback on the dropdown list. I also have a save buttonon the form and I know when the user clicks this, I can retrieve the value
in the listbox by doing a Request.Form("listboxID") on the server, however
the dropdownlist text changed event will occur before the save button is
clicked.

Any idea how I might preserve the users selection in the listboxes when I
present the screen back to them after the dropdown list text changed event?

Any help appreciated.
Thanks,
Kay.


Nov 18 '05 #3
What type of controls are you using? Are you using <select> elements or
<asp:ListBox> elements? Are you declaring these in your code behind? If your
Page.Load event handler or your declarative code is defining these elements
in their initial state, then you will need to detect IsPostBack and react
accordingly.

--
Chris Jackson
Software Engineer
Microsoft MVP - Windows Client
Windows XP Associate Expert
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--

"Kay" <ka********@proteus.ie> wrote in message
news:OD**************@tk2msftngp13.phx.gbl...
Hello,

I have two list boxes on my form, one initially displays with items and
the
other displays blank, by clicking a button, it is possible to move items
from one box to another and vice a versa, this works fine. I also have a
dropdown list on the page with autopost back = true, my problem is as
follows: when the user selects an option in the dropdown list the form is
posted back to the server and certain other processing happens, then when
the form redisplays, the items that had been moved between the list boxes
have disappeared. How do I maintain the listboxes on a redisplay?
I need to do an autopostback on the dropdown list. I also have a save
button
on the form and I know when the user clicks this, I can retrieve the value
in the listbox by doing a Request.Form("listboxID") on the server, however
the dropdownlist text changed event will occur before the save button is
clicked.

Any idea how I might preserve the users selection in the listboxes when I
present the screen back to them after the dropdown list text changed
event?

Any help appreciated.
Thanks,
Kay.

Nov 18 '05 #4
Kay
Hi Chris,

On the page load event in the code behind file, I populate one of the list
boxes, the other listbox is not filled. I also populate the dropdownlist.
EnableViewState is set to true for both the listboxes and the dropdown list.

I have no problem with the dropdown list, this works fine, my problem is
trying to preserve the contents of the listboxes after the form is posted
back to the server due to the text changed event firing for the dropdown
list. When items are moved between the list boxes they redisplay as they
were originally displayed i.e one listbox displays blank regardless of what
had been moved into it.

Thanks,
Kay.

..""Coucou à toutes et à tous"" <cm****@nospamplease.com> wrote in message
news:$A**************@cpmsftngxa07.phx.gbl...
Without knowing exactly how your code works, I only have a few simple
things to double check. First, are you writing any code in the Page_Load
method that would always overwrite the settings of your dropdown list?
Next, are you enabling the viewstate for each dropdown list?

Chris

--------------------
Reply-To: "Kay" <ka********@proteus.ie>
From: "Kay" <ka********@proteus.ie>
Subject: moving items from one list box to another
Date: Fri, 13 Feb 2004 15:08:15 -0000
Lines: 25
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
Message-ID: <OD**************@tk2msftngp13.phx.gbl>
Newsgroups: microsoft.public.dotnet.framework.aspnet
NNTP-Posting-Host: 62.17.23.97
Path:

cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTN GP08.phx.gbl!tk2msftngp13. phx.gbl
Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.framework.aspnet:209871X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

Hello,

I have two list boxes on my form, one initially displays with items and theother displays blank, by clicking a button, it is possible to move items
from one box to another and vice a versa, this works fine. I also have a
dropdown list on the page with autopost back = true, my problem is as
follows: when the user selects an option in the dropdown list the form is
posted back to the server and certain other processing happens, then when
the form redisplays, the items that had been moved between the list boxes
have disappeared. How do I maintain the listboxes on a redisplay?
I need to do an autopostback on the dropdown list. I also have a save

button
on the form and I know when the user clicks this, I can retrieve the valuein the listbox by doing a Request.Form("listboxID") on the server, howeverthe dropdownlist text changed event will occur before the save button is
clicked.

Any idea how I might preserve the users selection in the listboxes when I
present the screen back to them after the dropdown list text changed event?
Any help appreciated.
Thanks,
Kay.

Nov 18 '05 #5
Kay
Hi Chris,

I am using ASP controls i.e. ListBox and dropdown list are both asp. All my
controls are declared in the code behind. I am using visual studio.net and
drag these controls on to my form at design time. My problem is when the
form posts back to the server as a result of the text changed event on the
dropdown list, when the screen is redisplayed any items that were moved
between the list boxes are lost i.e. the listboxes display as they
originally did when the page was first displayed.

Thanks,
Kay

"Chris Jackson" <chrisjATmvpsDOTorgNOSPAM> wrote in message
news:OQ****************@TK2MSFTNGP09.phx.gbl...
What type of controls are you using? Are you using <select> elements or
<asp:ListBox> elements? Are you declaring these in your code behind? If your Page.Load event handler or your declarative code is defining these elements in their initial state, then you will need to detect IsPostBack and react
accordingly.

--
Chris Jackson
Software Engineer
Microsoft MVP - Windows Client
Windows XP Associate Expert
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--

"Kay" <ka********@proteus.ie> wrote in message
news:OD**************@tk2msftngp13.phx.gbl...
Hello,

I have two list boxes on my form, one initially displays with items and
the
other displays blank, by clicking a button, it is possible to move items
from one box to another and vice a versa, this works fine. I also have a
dropdown list on the page with autopost back = true, my problem is as
follows: when the user selects an option in the dropdown list the form is posted back to the server and certain other processing happens, then when the form redisplays, the items that had been moved between the list boxes have disappeared. How do I maintain the listboxes on a redisplay?
I need to do an autopostback on the dropdown list. I also have a save
button
on the form and I know when the user clicks this, I can retrieve the value in the listbox by doing a Request.Form("listboxID") on the server, however the dropdownlist text changed event will occur before the save button is
clicked.

Any idea how I might preserve the users selection in the listboxes when I present the screen back to them after the dropdown list text changed
event?

Any help appreciated.
Thanks,
Kay.


Nov 18 '05 #6

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

Similar topics

12
by: Kevin Blount | last post by:
I'm playing with dragable <DIV>s, being inspired by google.com/ig, where you can move items on the page around and have items you move over change position if necessary. I have 3 div's setup,...
3
by: Kay | last post by:
Hello, I have two list boxes on my form, one initially displays blank, and through javascript it is possible to move items from one box to another, this works fine, I followed an article titled...
2
by: florin | last post by:
I have to ListBox controls (or 2 html select controls with runat=server) on a web page and some buttons to move data from one listbox to another (using javascript). The problem is that when the...
1
by: Partha Sarathy.G | last post by:
I have code for moving the items from one list box to another listbox at client side For more details mail to gps.mca@gmail.com
3
by: Dany P. Wu | last post by:
Hi everyone, One of my Windows forms contain two listbox controls, with Add and Remove buttons between them. The idea is to allow users to select multiple items from one ListBox, click the...
6
by: Matt | last post by:
I'm not entirely sure how to describe this issue. I have a number of ComboBoxes in my application which have their text properties bound to a field in a data set. The items loaded in the ComboBox...
1
by: OwlHoot | last post by:
I am using Thomas Fuchs's amazing drag-and-drop JavaScript library available at: http://wiki.script.aculo.us/scriptaculous/show/DragAndDrop to allow the user to select a subset of items listed...
1
by: MayhemMickells | last post by:
Alright soo, I'm working on this program for my programming class using VB 2005 and it's driving me insane. See the program is like this. The main form has a list box for selected products and...
4
by: HMS Surprise | last post by:
Just wondered if there was some python idiom for moving a few items from one list to another. I often need to delete 2 or 3 items from one list and put them in another. Delete doesn't seem to have...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.