1. 数据绑定
代码
this
.DropDownList1.DataSource
=
CategoryManager.getCategories();
DropDownList1.DataValueField = " id " ; // 用来设置下拉列表选中的 Value 值
DropDownList1.DataTextField = " name " ; // 为下拉列表选项显示的值
DropDownList1.DataBind();
DropDownList1.DataValueField = " id " ; // 用来设置下拉列表选中的 Value 值
DropDownList1.DataTextField = " name " ; // 为下拉列表选项显示的值
DropDownList1.DataBind();
2.读取数据
int
categoryId
=
int
.Parse(
this
.DropDownList1.SelectedItem.Value);
//
获取下拉列表中选中的值