怎么用.net代码实现gridview的模糊查询。(怎么实现在没有按button键的时候gridview里仍是有内容的) 20
代码部分如下SqlConnectionconn=newSqlConnection("server=.\\sqlexpress;database=MDB;uid=sa;pw...
代码部分如下
SqlConnection conn = new SqlConnection("server=.\\sqlexpress;database=MDB;uid=sa;pwd=123456");
SqlCommand cmd = new SqlCommand("select ntime,title,text,reporter from News where title like '%" + TextBox1 .Text + "%'", conn);
DataSet ds = new DataSet();
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.Fill(ds, "t1");
GridView2.DataSource = ds.Tables["t1"];
GridView2.DataBind(); 展开
SqlConnection conn = new SqlConnection("server=.\\sqlexpress;database=MDB;uid=sa;pwd=123456");
SqlCommand cmd = new SqlCommand("select ntime,title,text,reporter from News where title like '%" + TextBox1 .Text + "%'", conn);
DataSet ds = new DataSet();
SqlDataAdapter sda = new SqlDataAdapter(cmd);
sda.Fill(ds, "t1");
GridView2.DataSource = ds.Tables["t1"];
GridView2.DataBind(); 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询