• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 388
  • Last Modified:

Webpage reloads when paging gridview

Hi Experts!

I have a gridview with paging.
The paging works fine, but when ever I page it seams like the complete webpage is reloaded.
This is not good since the gridview is located far down on my page, and the users needs to scroll down for each pageing.
Could someone tell me what I am doing wrong?

Here is my code:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  If Not Page.IsPostBack Then
      loadGrid()
  End If
End Sub

Protected Sub ProductGrid_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs) Handles ProductGrid.PageIndexChanging
    ProductGrid.PageIndex = e.NewPageIndex
    loadGrid()
End Sub

GridView
########

<asp:GridView id="ProductGrid" Runat="Server" AllowPaging="True" PageSize="1"
      AutoGenerateColumns="False" PagerSettings-Position=Bottom PagerSettings-Mode=NextPrevious
      PagerSettings-FirstPageImageUrl="~/CommonFiles/Images/readMore.jpg"
      PagerSettings-PreviousPageImageUrl="~/CommonFiles/Images/readMore.jpg"
      PagerSettings-NextPageImageUrl="~/CommonFiles/Images/readMore.jpg"
      PagerSettings-LastPageImageUrl="~/CommonFiles/Images/readMore.jpg"
      PagerStyle-HorizontalAlign="Center" GridLines="None">
<Columns>
        <asp:TemplateField>
        <ItemTemplate>
...
0
gfk76
Asked:
gfk76
1 Solution
 
Jason ScolaroCommented:
This is the default action of paging for a GridView, to cause a PostBack.  You can turn on a page directive to make the page stay at the last scroll position:

<%@ Page MaintainScrollPositionOnPostBack="true" />

http://msdn2.microsoft.com/en-us/library/system.web.ui.page.maintainscrollpositiononpostback(VS.80).aspx

-- Jason
0
 
gfk76Author Commented:
Thank you!
This was just what I needed.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now