方法1:
DropDownList1.DataSource=ds.Tables[0].DefaultView; DropDownList1.DataTextField = "item_name" DropDownList1.DataValueField = "item_id" DropDownList1.DataBind();
方法2:
for(int i = 0;i<ds.table[0].row.count;i++){
dropdownlist.item.add(ds.table[0].rows[i]["name"].tostring());
}
方法3:
dropdownlist1.item.add(new listitem(text,value));
今天用到了第三种方法,因为要给一个dropdownlist动态bind不同的text和value值,大家还有什么好的办法,欢迎指点!