DropDownList value lost on PostBack
June 10, 2009
I had two dropdownlists. One that was hard-coded in the .aspx page and one that was being dynamically populated in the code-behind. I had a requiredfieldvalidator on both..
When I submit it would get past the client side validation. Server side validation
If(Page.IsValid) was failing.
It would come back to the page saying that I needed to choose a value for my dynamically populated ddl.
For the life of me I couldn’t figure it out.
Finally I noticed at the top in the page directive:
EnableViewState="false"
I set this to true and it worked.
Conclusion: if you’re finding values aren’t making it to the code-behind check your ViewState.
I hope this saves someone else the time I lost debugging it.
-
Categories
- asp.net (11)
- Blog (1)
- Business (5)
- Conferences (1)
- Errors (3)
- Portfolio (2)
- Reviews (2)
- SQL Server (3)
- Tips (1)
- Uncategorized (1)
- Web Development (13)
-
Archives