如何将数据源绑定到DropDownList实现长尾词查询?
- 内容介绍
- 文章标签
- 相关推荐
本文共计192个文字,预计阅读时间需要1分钟。
csharppublic bool ecDropDownList(DropDownList DDL, string sqlstr3, string DTF, string DVF){ 创建数据库连接 SqlConn public bool ecDropDownList(DropDownList DDL, string sqlstr3, string DTF, string DVF) { // 创建数据库连接 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");}
本文共计192个文字,预计阅读时间需要1分钟。
csharppublic bool ecDropDownList(DropDownList DDL, string sqlstr3, string DTF, string DVF){ 创建数据库连接 SqlConn public bool ecDropDownList(DropDownList DDL, string sqlstr3, string DTF, string DVF) { // 创建数据库连接 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");}

