1绑定DataTable 简单直接下部分就ok了

this.DropDownList1.DataSource = DataTable;

this.DropDownList1.DataTextField = "Name";
this.DropDownList1.DataValueField = "id";

this.DropDownList1.DataBind();

 

但是如果循环绑定就有几个坑

this.DropDownList1.Items.Insert 绑定设置一个请选择还好, 设置多个不介意使用  设置Value和排序显示有时候有冲突

 

建议使用下面这一种,千万注意写法

this.DDL_Column.Items.Add(new ListItem(name, id));

一定不要再ListItem里面拼接字符串啊,里面不能拼接,这个一个坑

 

posted on 2017-07-11 16:37  Geok  阅读(263)  评论(0编辑  收藏  举报