asp.net GridView无法显示搜索后的结果,应该是没有成功绑定,高手帮忙看下
protectedvoidButton1_onclick(objectsender,EventArgse){SqlConnectionconn=newSqlConnect...
protected void Button1_onclick(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection(@"Data Source=admin-pc;Initial Catalog=store;Integrated Security=True");
// string sql = "SELECT * FROM 商品信息数据表 WHERE szItemID='" + TextBox1.Text + "'";
string sql = "SELECT * FROM 商品信息数据表 ";
SqlDataAdapter adpater = new SqlDataAdapter(sql, conn);
DataSet ds = new DataSet();
adpater.Fill(ds);
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
conn.Close();
}
点击按钮后,没有显示,但是按钮是可以响应的,试过跳到另一个页面,这样绑定哪里错了呢? 展开
{
SqlConnection conn = new SqlConnection(@"Data Source=admin-pc;Initial Catalog=store;Integrated Security=True");
// string sql = "SELECT * FROM 商品信息数据表 WHERE szItemID='" + TextBox1.Text + "'";
string sql = "SELECT * FROM 商品信息数据表 ";
SqlDataAdapter adpater = new SqlDataAdapter(sql, conn);
DataSet ds = new DataSet();
adpater.Fill(ds);
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
conn.Close();
}
点击按钮后,没有显示,但是按钮是可以响应的,试过跳到另一个页面,这样绑定哪里错了呢? 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询