views:

22

answers:

1

I have a page with a ASP.NET DropDownBox control (HTML select) that's populated with some dynamic record values. When the user selects a record the entire contents of the page is updated to reflect the selection. If a user clicks a link and leaves the page and tries to go back, it pulls up the default unselected list, and they have to reselect it again. How would be the best way to retain their selection? I currently have the page set so if the url contains PageName.aspx?recordID=5 it will select the correct dropDown option. However I'm not sure how to change the URL's query string based on the selection.

+1  A: 

You could throw the recordID into ViewState

ViewState["recordID"] = 5;

instead of carrying the selection in Query String. You can check for it on page load; if it's not null then set the dropdown control appropriately.

Bala R
I'd forgotten all about the ability to manually put things into the viewstate...
jamone