asp.net btn控件查询数据放入gridview,分页后,第一页正常,第二页不显示,需点击btn才显示,这个要怎么改?
btn_click:stringsc="selectXXXXfrom[dbo].[Store_in]";SqlDataAdaptersa=newSqlDataAdapte...
btn_click:
string sc = "select XXXX from [dbo].[Store_in]";
SqlDataAdapter sa = new SqlDataAdapter(sc, sqlcnn);
sa.Fill(ds, "table");
GridView1.DataSource = ds.Tables["table"].DefaultView;
GridView1.DataBind()
GridView1_PageIndexChanging:
GridView1.PageIndex = e.NewPageIndex;
GridView1.DataBind(); 展开
string sc = "select XXXX from [dbo].[Store_in]";
SqlDataAdapter sa = new SqlDataAdapter(sc, sqlcnn);
sa.Fill(ds, "table");
GridView1.DataSource = ds.Tables["table"].DefaultView;
GridView1.DataBind()
GridView1_PageIndexChanging:
GridView1.PageIndex = e.NewPageIndex;
GridView1.DataBind(); 展开
1个回答
展开全部
可能PageIndexChanging事件没有重新绑定数据,(这代码贴的不全,看不出什么)
更多追问追答
追问
GridView1_PageIndexChanging:
GridView1.PageIndex = e.NewPageIndex;
GridView1.DataBind();
已经进行绑定了,还是要怎么绑定
追答
GridView1_PageIndexChanging:
GridView1.PageIndex = e.NewPageIndex;
GridView1.DataBind();
绑定事件里只有这两句吗?这样的话把,最后一句GridView1.DataBind();换成你的这段
string sc = "select XXXX from [dbo].[Store_in]";
SqlDataAdapter sa = new SqlDataAdapter(sc, sqlcnn);
sa.Fill(ds, "table");
GridView1.DataSource = ds.Tables["table"].DefaultView;
GridView1.DataBind();
绑定意思是重新获取数据,不只是DataBind();
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询