publicboolecDropDownList(DropDownListDDL,stringsqlstr3,stringDTF,stringDVF){创建数据库连接SqlConn public bool ecDropDownList(DropDownList DDL, string sqlstr3, string DTF, string DVF){//创建数据库连接SqlConnection con this.getco
public bool ecDropDownList(DropDownList DDL, string sqlstr3, string DTF, string DVF){//创建数据库连接SqlConnection con this.getcon();//打开数据库连接con.Open();//定义并初使化数据适配器SqlDataAdapter mydataadapter new SqlDataAdapter(sqlstr3,con);//创建一个数据集mydatasetDataSet mydataset new DataSet();//将数据适配器中的数据填充到数据集中mydataadapter.Fill(mydataset);DDL.DataSource mydataset;DDL.DataTextField DTF;DDL.DataValueField DVF;try{DDL.DataBind();return true;}catch{return false;}finally{//关闭数据库连接con.Close();}}
与之相关联的DropDownList的数据绑定
public void GetDropDownList(){dataconn.ecDropDownList(ddlSelQue, "select * from tb_TaoTi where LessonID" ddlSelLess.SelectedValue.ToString() "", "Name", "ID");}