Empty DropDown After Submit your Form and Information Lost

My case:
It’s a standard register form created in a SharePoint WebPart (but this error could happen even if you’re not using SharePoint). When I submit the form, sometimes I loose the information of DropDowns (but not the information of textboxes) and it seems to happen randomly.
I checked the packages sent with Wireshark and I see that the information is sent to the server. I debug the server code and I see that when I try to get the information of DropDowns (to save it to the database) it’s empty.
Explanation:
I load the DropDowns information in the Page_Load event. I used a “if(!Page.IsPostBack)” in order to load the information only when the page is first loaded. The problem is that Page_Load event depends on the network, browser… and this could happen.
Solution:
Load the DropDown source in the OnInit event. You don’t have to check if it’s postback or not. Directly load the data you need here.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.