Home > Net >  Dropdownlist bound data, why is selected by default first
Dropdownlist bound data, why is selected by default first

Time:03-04

Dropdownlist bound data, why the first selected by default, I don't want it selected,

 

Onselectedindexchanged="PID_SelectedIndexChanged" & gt;
& nbsp;





Data binding PID code
 
if (! IsPostBack)
{
//bind data
String strSql="";
StrSql="select ProvinceID, ProvinceSortID, ProvinceName, AddTime from table name order by ProvinceSortID";

DataView dv=cai_Province. QueryProvince (strSql);
PID. DataValueField=dv. Table. The Columns [0]. The Caption;
PID. DataTextField=dv. Table. The Columns [2]. The Caption;
PID. The DataSource=dv;
PID. DataBind ();
}

CodePudding user response:

Not don't want to be the first article is selected by default, but you can add an empty in front, set AppendDataBoundItems="true", so as not to select the data source in the first article

CodePudding user response:

Hello World, 1/f, reference response:
don't want to be selected by default the first is not enough, but you can add an empty in front, set AppendDataBoundItems="true", so as not to select the data source of the first article


This is to modify the page, that is, binding data first, and then to the selected value is another list,

CodePudding user response:

Then set the one for the selected state, set SelectedValue, or SelectedIndex or SelectedItem

CodePudding user response:

Useless,
Strange, mobile, PC version not line, mobile phone version of the code from the PC version of the copy of the past,

CodePudding user response:

Just change the browser may
  • Related