Paging in Gridview

Here i am goin to give Code snippets for paging in gridview.

First make the property AllowPaging = True.
By using PagerSettings we can change the Pager Tepmlate.PagerSettings have properties like FirstPageText,LastPageText,NextPageText,PreviousPageText.

So our gridview look like this,


<asp:GridView ID="gvwData" runat="server" AllowPaging="True" PageSize="5" OnPageIndexChanging="dGrid_PageIndexChanging">
<PagerSettings FirstPageText="First" LastPageText="Last" NextPageText="Next" PreviousPageText="Previous" />
<Columns>
......
</Columns>
</asp:GridView>


Then create event for gridview,PageIndexChanging


protected void gvw_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gvwData.PageIndex = e.NewPageIndex;
FillGridAgain();
}


Comments

No responses found. Be the first to comment...


  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: