How to do paging in datagrid?

Last post 07-05-2009 1:39 PM by alessandro. 2 replies.

Sort Posts:

  • How to do paging in datagrid?

    07-05-2009, 5:53 AM

    Hello friends

    I want to know how should paging be implemented in a datagrid in asp.net 1.1.

    I want that all the records when fetched from the database should be shown not in a single page. Instead 10 records per page should be shown. Clicking the next button should show the next 10 records.

    Kindly help.

    Thanks in advance.

  • Re: How to do paging in datagrid?

    07-05-2009, 8:08 AM
    Answer
    • Member
      178 point Member
    • pavan496
    • Member since 06-18-2009, 8:44 PM
    • Hyderabad
    • Posts 61

    Hello,

    You can use the paging feature that is build in datagrid.

    To enable paging, set the AllowPaging property of the datagrid to true.

    Select your page size as per required and in the pageindexchanging event of the gridview, write down the following code

    GridView1.PageIndex = e.NewPageIndex;
    GridView1.DataBind();

    This will do it, hopefully

    PaVaN
  • Re: How to do paging in datagrid?

    07-05-2009, 1:39 PM
    • Contributor
      6,788 point Contributor
    • alessandro
    • Member since 06-25-2002, 10:05 AM
    • Italy
    • Posts 1,103

    for datagrid in 1.1 , you need to set AllowPaging to true and CurrentPageIndex = e.NewPageIndex, while passing your datasource to the datasource property + databind in the PageIndexChanged event handler of your datagrid eg :

    http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.datagrid.allowpaging.aspx

    Follow the sample code above. It's specific to datagrid.


    Alessandro Zifiglio
    www.jiffycms.net - opensource HTML Editor for ASP.NET
    http://weblogs.asp.net/alessandro


    In the land of the blind, the man with one eye is king!:x
Page 1 of 1 (3 items)