您的位置:首页 > 运维架构

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

2010-11-13 00:47 232 查看
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代表位置


红色或者蓝色单独使用,都可以
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: