Custom paging in grid view control

422 views Asked by At

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 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?

1

There are 1 answers

1
Muhammad Akhtar On BEST ANSWER

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();
}