前台:
<asp:DropDownList ID="DropDownList1" runat="server" Width="600px" AppendDataBoundItems="true">
</asp:DropDownList>
后台:
string sql = "select * from 月报表table2重大隐患类型";
DataTable dt = CommonApp.getCompanyInfo(sql).Tables[0];
DropDownList1.DataSource = dt;
DropDownList1.DataTextField = "重大隐患名称";
DropDownList1.DataValueField = "id";
DropDownList1.Items.Insert(0, new ListItem("--请选择--", ""));
DropDownList1.DataBind();
dt.Dispose();
ShowData();