前端页面代码
</asp:Label> <asp:DropDownList
ID="ddlKm" runat="server"></asp:DropDownList>
.cs文件
private void BindDropDownList()
{
SqlConnection conn = BaseClass.DBCon();
conn.Open();
SqlCommand cmd = new SqlCommand("select * from tb_Lesson", conn);
SqlDataReader sdr = cmd.ExecuteReader();
ddlKm.DataSource = sdr;
ddlKm.DataTextField = "LessonName";
ddlKm.DataBind();
conn.Close();
}
数据库