简体   繁体   English

网格视图控件中的自定义分页

[英]Custom paging in grid view control

I want custom pagination in my gridview control. 我想在我的gridview控件中自定义分页。 The first option is to fetch only required row from the data base. 第一种选择是仅从数据库中获取所需的行。 But what I want is I am fetching all rows from the database and storing them into datatable. 但是我想要的是我正在从数据库中获取所有行并将它们存储到数据表中。 Now is there any option that I can bind only some of the rows of datatable to gridview based on page size and page index so that I no need to connect to database every time on page change event? 现在有什么选择可以根据页面大小和页面索引将数据表的某些行仅绑定到Gridview,这样就不必每次页面更改事件时都连接到数据库?

You have to handle the Gridview PageIndexChanging event and setup a New page index. 您必须处理Gridview PageIndexChanging事件并设置一个新页面索引。

like... 喜欢...

protected void gridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
   gridView.PageIndex = e.NewPageIndex;
   gridView.DataSource = (DataTable)Session["DataTable"];
   gridView.DataBind();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM