F: About DROPDOWNLIST, Postback

xiaoxiao2021-03-06  77

Original question: if (! Page.ispostback) {.... this.dropdownlist1.datasource = this.sqlcommand1.executeReader (); this.dropdownlist1.database.Database

How do you execute a DataBind in Postback? Oh, tossing for a day.

In this case, it will not be able to get the value of DropDownList changes, because each postback is re-databind, and the value is restored?

Reply:

IF (! page.ispostback)

{

....

THIS.DROPDOWNLIST1.DATASOURCE = this.sqlcommand1.executeReader ();

This.dropdownList1.Database (); // The code here does not execute when postback

}

If you happen to see if the Vale value of all items is the same, DropDownload only saves the Vale value in ViewState and decides the option after Postback.

转载请注明原文地址:https://www.9cbs.com/read-93154.html

New Post(0)