给dropdownlist手动添加一列"--请选择--"(不是从数据库中读取的数据)
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindJueSe();
}
}
public void BindJueSe()
{
ddljuese.DataSource = DAL.Juese();
ddljuese.DataValueField = "userrole_id";
ddljuese.DataTextField = "userrole_name";
ddljuese.DataBind();
ddljuese.Items.Insert(0, new ListItem("--请选择--", "0")); //如果是ddljuese.Items.Insert(0, new ListItem(" "," "));插入空值。
//或者
//ListItem it = new ListItem("--请选择--", "0");
//ddljuese.Items.Insert(0, it);
//或者(这样“请选择会出现在最后一列”)
//ListItem lt = new ListItem();
//lt.Text = "--请选择--";
//lt.Value = "00";
//lt.Selected = true;
//ddljuese.Items.Add(lt);
}