tags:

views:

117

answers:

3

I have a drop down that is NOT keeping the value that I select. I already check to True the EnableViewState and nothing yet. What may be missing here? Any advise is appreciated.

+4  A: 

Check your Page_Load method. Make sure when you populate it and select the default value it is inside an

if(!IsPostBack) { .. . . }

You could be accidentally setting it on each post back, which is why it seems like it is not retaining its value.

David Basarab
I've made this mistake before.
David
Thanks a bunch. I was assigning a Request in the page load that was carrying nothing.
+5  A: 

If you're filling it in the Page_Load(), it will get overwritten each time the page loads. If you want the user selection to persist, fill it in the Page_Init(). The viewstate is applied in between the Page_Load and the Page_Init, so this will ensure proper order of execution.

For more info, look up the Page Lifecycle for ASsp.Net.

David Stratton
Thanks a bunch. Good to re-think this facts which I was doing but my problem was thatI was assigning a Request in the page load that was carrying nothing.
Thanks a bunch. I was assigning a Request in the page load that was carrying nothing.
This was my problem
A: 

where are you binding your Dropsown list? Make sure that you do following:

if(!IsPostBack)

{

//Do your data binding here

}

Neil