0

In an ASP.Net GridView, are you experiencing this?

A web form has a GridView and also a DetailsView. The user pages to a particular page such as page 3. The pager shows the current page is page 3. Next the user clicks on one of the select buttons in the GridView. The pager now shows the current page as being page 1 but the GridView shows the data from page 3. The pager and the current page are now out of sync.

This is the code-behind that is being used to allow the paging to work:

Protected Sub GridViewSummary_PageIndexChanging(sender As Object, e As GridViewPageEventArgs) Handles GridViewSummary.PageIndexChanging
    GridViewSummary.DataSource = theTableAdapter.GetDataByAllClasses(TextBoxSearch.Text)
    GridViewSummary.PageIndex = e.NewPageIndex
    GridViewSummary.DataBind()
End Sub

Is there a way to get the pager to correctly sync the page numbers with the current page being viewed?

Emad-ud-deen
  • 4,734
  • 21
  • 87
  • 152

1 Answers1

0

If the page index and data are going out of sync when you select a record, I'd suggest looking at your Protected Sub GridViewSummary_SelectedIndexChanging(sender As Object, e As GridViewPageEventArgs) Handles GridViewSummary.SelectedIndexChanging handler. Does this change the page index?

The code you posted looks ok to me.

Patrick Allwood
  • 1,822
  • 17
  • 21
  • Thanks for the answer. We are not using SelectedIndexChanging. If we need to use it, can you show the needed coding we need to include? Thanks. – Emad-ud-deen Apr 03 '13 at 16:28