asp.net Dropdown list no selected item in code behind.

jfsedlar3rd
jfsedlar3rd used Ask the Experts™
on
I have been beating my head on the desk. I am writing a asp.net app in Visual Studio 2010 I filled a dropdown list via a SQL 2008 table the same way i do in Visual Studio 2008. The ddl populates fine however when I punch a save button the selected value is not available in the code behind. I am using master pages.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
On click your page gets post back so it will again populate your dropdown so you won't get selected value of the same. You can place the control in Updatepanel which will stop page postback and you get control's value

Author

Commented:
Why have I not seen this functionality in the past? is there something not configured right with my viewstate?
no its not with configuring with viewstate. When you click on button page get post back so if you have write code to bind the dropdown in page load, it will again bind the drop down so you dont get the previously selected value.

Author

Commented:
Duh I forgot the  If Not IsPostBack. Thanks a lot.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial