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

moving items from one list box to another

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.