如何用DropDownList来实现Gridview的查询,
我想用Gridview控件根据DropDownList下拉的值来实现显示功能、有个Button控件、在Button单击事件是代码如下、SqlConnectionconn=...
我想用Gridview控件根据DropDownList下拉的值来实现显示功能、有个Button控件、在Button单击事件是代码如下、
SqlConnection conn = new SqlConnection("Server=.;database=Teasell;integrated security=sspi");
conn.Open();
string sql = "select * from Tea where teaname=" + DropDownList1.SelectedValue;
SqlDataAdapter ad = new SqlDataAdapter(sql, conn);
DataSet ds = new DataSet();
ad.Fill(ds, "Tea");
GridView1.DataSource = ds.Tables["Tea"].DefaultView;
GridView1.DataBind();
出现了下面的问题
求大神帮忙看看怎么处理这个问题~~好了加分~~谢谢 展开
SqlConnection conn = new SqlConnection("Server=.;database=Teasell;integrated security=sspi");
conn.Open();
string sql = "select * from Tea where teaname=" + DropDownList1.SelectedValue;
SqlDataAdapter ad = new SqlDataAdapter(sql, conn);
DataSet ds = new DataSet();
ad.Fill(ds, "Tea");
GridView1.DataSource = ds.Tables["Tea"].DefaultView;
GridView1.DataBind();
出现了下面的问题
求大神帮忙看看怎么处理这个问题~~好了加分~~谢谢 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询