After clicking the submit button the value of DropDownList becomes the default value for analysis

  • 2020-06-07 04:22:24
  • OfStack

After clicking the Submit button, all the control values bound to the database on the page are restored to their default values

The reason is to write the binding function loadData() in

if(!IsPostBack)
{
Your binding function;
}
Otherwise, the page reloads and the values of all controls become their original values.

IsPostBack is an Page class that has a property of type bool to determine whether the current page is being loaded in response to a client postback or is being first loaded and accessed.

When IsPostBack = true is loaded in response to a client postback.
When IsPostBack = false means that it is being first loaded and accessed.

Bind the function only if IsPostBack = false, so as not to cause the page to reload and cause the page control to initialize.

IsPostBack is introduced:
http://msdn.microsoft.com/en-us/library/system.web.ui.page.ispostback.aspx
http://www.cxy.me/doc/5446.htm

Related articles: