Saving on SelectedIndexChanged

  • Thread starter james_strugnell
  • Start date
J

james_strugnell

Any ideas on what the best method is for the following: I have a
dropdownlist which determines some of the contents of the rest of the
page. The Dropdownlist's AutoPostback is set to true so when a user
changes the item in the list the page gets reloaded with new
information. My problem is that if they change any of the related info
I need to save it in the postback, presumably in the
SelectedIndexChanged event. I only seem to be able to access the newly
selected item and therefore cannot save the previous item's details.
This seems like a fairly standard process but I can't seem to see the
best way of doing it.

Any ideas?
 
W

Ward Bekker

Hi James,

You could save the current selected item's details in the viewstate.

ViewState["myInfo"] = yourObject


When there is a postback, you can get the old info, and set it again
with the new selected item.

Make sure that your object /info is Serializable, otherwise it cannot
be placed inside the viewstate if I'm not mistaken

--
Ward Bekker
"Asp.Net Discussions for the Professional Developer"
http://www.dotnettaxi.com

"Free .Net 2.0 C# to/from VB.Net Code Converter"
http://www.dotnettaxi.com/Tools/Converter.aspx
 
J

james_strugnell

Hi Ward,

Thanks for this. I did try this method myself, but my code seemed to
get very confusing and I was wondering if there was another way. I
guess not. If anyone else has any other methods I would appreciate
hearing them, otherwise it looks like Viewstate is the way.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top