DropDownList 后台添加一个默认值,并选中

来源:互联网 发布:农村淘宝商业计划书 编辑:程序博客网 时间:2024/05/01 15:05
   this.DropDownList1.DataBind();
                //需要在最后一行,在绑定数据的后面
                this.DropDownList1.Items.Insert( 0, new ListItem("---选择类型---", "0"));
                this.DropDownList1.SelectedIndex = 0; //默认选中的索引,这里就是diygi9e

注意就是要在绑定的后面,开始我在网上搜的,我放在绑定的前面,始终不对,