开发者

Custom paging in grid view control

开发者 https://www.devze.com 2023-02-27 10:21 出处:网络
I want custom pagination in my gridview control. The first option is to fetch only required row from the data base. But what I want is开发者_如何学C I am fetching all rows from the database and storin

I want custom pagination in my gridview control. The first option is to fetch only required row from the data base. But what I want is开发者_如何学C 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?


You have to handle the Gridview PageIndexChanging event and setup a New page index.

like...

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号