public void initList(DataTable dt)
{
DropDownList1.DataSource = dt;
DropDownList1.DataTextField = "empName";
DropDownList1.DataValueField = "empNumber";
DropDownList1.DataBind();
}
public void initList2(DataTable dt)
{
foreach (DataRow r in dt.Rows)
{
DropDownList2.Items.Add(new ListItem(r["empName"].ToString(), r["empNumber"].ToString()));
}
}
public void initList3(DataTable dt)
{
foreach (DataRow r in dt.Rows)
{
DropDownList3.Items.Add(new ListItem(r[0].ToString(), r[1].ToString()));
}
}
3种DropDownList绑定方法效率1<2<3
3种DropDownList绑定方法效率
最新推荐文章于 2020-06-26 19:49:13 发布