DropDownList使用方法:
和 datatable 绑定
(1)
datatable dt = new datatable();
this.DropDownList.DataSource = dt;
this.DropDownList.DataValueField = "Type_ID";
this.DropDownList.DataTextField = "Type_Name";
this.DropDownList.DataBind();
this.DropDownList.Items.Add(new ListItem("请选择",""));
(2)
datatable dt = new datatable();
this.DropDownList.Items.Add(new ListItem("---请选择---",""));
if(dt.Rows.count > 0)
{
foreach(DataRow dr in dt.Rows)
{
this.DropDownList.Items.Add(new ListItem(dr["Type_name"].ToString(),dr["Type_ID"].ToString()));
}
}
和 对象数组绑定
(1)
NAV_INFOTYPEINFO[] infomodels = Select();
this.DropDownList.DataSource = infomodels;
this.DropDownList.DataTextField = &
和 datatable 绑定
(1)
datatable dt = new datatable();
this.DropDownList.DataSource = dt;
this.DropDownList.DataValueField = "Type_ID";
this.DropDownList.DataTextField = "Type_Name";
this.DropDownList.DataBind();
this.DropDownList.Items.Add(new ListItem("请选择",""));
(2)
datatable dt = new datatable();
this.DropDownList.Items.Add(new ListItem("---请选择---",""));
if(dt.Rows.count > 0)
{
foreach(DataRow dr in dt.Rows)
{
this.DropDownList.Items.Add(new ListItem(dr["Type_name"].ToString(),dr["Type_ID"].ToString()));
}
}
和 对象数组绑定
(1)
NAV_INFOTYPEINFO[] infomodels = Select();
this.DropDownList.DataSource = infomodels;
this.DropDownList.DataTextField = &