1.在.aspx页面拖入DropDownList控件
<label class="txt-green">校区:</label>
<asp:DropDownList ID="ddlCampus" Width="120px" Height="25px" runat="server"
AutoPostBack="True" onselectedindexchanged="ddlCampus_SelectedIndexChanged">
</asp:DropDownList>
2.在.aspx.cs页面中,编写DropDownList绑定数据库表值的方法
private void bindCampus() {
//调用建筑业务逻辑层,查询现存校区信息
DataTable dtCampus = new BuildingBLL().QueryCampus(); //集合
//绑定校区信息,并添加新行
CourtName cn = new CourtName();//单一实例化
cn.ID = 0;
cn.ICourt = "请选择";
dtCampus.Insert(0,cn);
//绑定校区信息
ddlCampus.DataSource = dtCampus;
//校区名
ddlCampus.DataTextField = "CampusName";
//校区ID
ddlCampus.DataValueField = "CampusID";
ddlCampus.DataBind();
}