如何让一个DropDownList绑定值后默认值为空

时间:2022-12-03 09:51:52
SqlConnection con = new SqlConnection("server=.;uid=sa;database=pubs");        
SqlDataAdapter sdr = new SqlDataAdapter("select * from employee",con);        
DataSet ds = new DataSet();        
sdr.Fill(ds);        
DropDownList1.DataSource = ds;        
DropDownList1.DataTextField = "emp_id";        
DropDownList1.DataBind();        
DropDownList1.Items.Add(" ");        
DropDownList1.Items[this.DropDownList1.Items.Count - 1].Value = " ";        
DropDownList1.SelectedIndex = this.DropDownList1.Items.Count - 1;
-----------------------------------------------------------------
 
this.ddl_xmjl.Items.Insert(0, new ListItem("", "0")); //单独使用,0代表位置
红色或者蓝色单独使用,都可以