ASP GridView分页设置方法
ASP Fromwork 4.8 Web Site GridView分页设置方法
aspx文件中设置分页参数,并添加事件OnPageIndexChanging
ageIndex="0" AllowPaging="True" PageSize="20" PagerSettings-Position="Bottom" HorizontalAlign="Center" PagerSettings-Visible="True" OnPageIndexChanging="GridView2_PageIndexChanging"

aspx.cs编写事件相应代码:
private void GridView2DataBind() { string str_sql = "select * from tb_testplanpo where pe_ID in(select min(pe_ID) from tb_testplanpo where Test_Result is null "; str_sql += " group by testplan_ID) order by AddTime desc"; DataBase db = new DataBase(); DataSet ds = db.GetDataSetSql(str_sql); GridView2.DataSource = ds; GridView2.DataBind(); int rowCount = ds.Tables[0].Rows.Count; int starIndex = GridView2.PageIndex * GridView2.PageSize + 1;//计算行首编号 for (int i = 0; i < GridView2.Rows.Count; i++) { GridView2.Rows[i].Cells[0].Text = (i + starIndex).ToString(); } } protected void GridView2_PageIndexChanging(object sender, GridViewPageEventArgs e) { GridView2.PageIndex = e.NewPageIndex; GridView2DataBind();//设定页面索引后必须重新更新一次数据 }
参考资料:https://www.cnblogs.com/lerit/archive/2011/08/18/2144787.html
转载请注明出处:https://www.cnblogs.com/lei-zi/

浙公网安备 33010602011771号