1

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?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Microsoft Developer
  • 5,229
  • 22
  • 93
  • 142

1 Answers1

1

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();
}
Off The Gold
  • 1,228
  • 15
  • 28
Muhammad Akhtar
  • 51,913
  • 37
  • 138
  • 191