asp.net根据Textbox输入数据,点击Button,Gridview中不显示我查询到的数据
代码如下:protectedvoidButton1_Click(objectsender,EventArgse){DataSetds=newDataSet();SqlCo...
代码如下:
protected void Button1_Click(object sender, EventArgs e)
{
DataSet ds = new DataSet();
SqlConnection scn = new SqlConnection();
scn.ConnectionString = "Data Source=.;Initial Catalog=Qyw;Integrated Security=True";
scn.Open();
SqlCommand scmd = new SqlCommand();
scmd.Connection = scn;
scmd.CommandText = "select * from Ribao where JobName like '%" + TextBox1.Text.Trim() + "%'";
SqlDataAdapter sda = new SqlDataAdapter(scmd);
sda.Fill(ds, "stu");
GridView1.DataSource = ds;
GridView1.DataMember = "stu";
GridView1.DataBind();
}
为什么?大神教教我 展开
protected void Button1_Click(object sender, EventArgs e)
{
DataSet ds = new DataSet();
SqlConnection scn = new SqlConnection();
scn.ConnectionString = "Data Source=.;Initial Catalog=Qyw;Integrated Security=True";
scn.Open();
SqlCommand scmd = new SqlCommand();
scmd.Connection = scn;
scmd.CommandText = "select * from Ribao where JobName like '%" + TextBox1.Text.Trim() + "%'";
SqlDataAdapter sda = new SqlDataAdapter(scmd);
sda.Fill(ds, "stu");
GridView1.DataSource = ds;
GridView1.DataMember = "stu";
GridView1.DataBind();
}
为什么?大神教教我 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询