Search code examples
c#asp.netgridviewpaginationcustompaging

how to achieve paging in a grid view in code


I'm using ASP.net web application with c#. In my web application I have a webpage with a data grid view.

I'm using this method to bind data to data grid view

 public void fillGridByALLBDetails()
    {
        GVView01.DataSource = new LibraryCatalogueOP().getLibraryCatalogue();
        GVView01.DataBind();   
    }

I'm calling the data grid view bind method in the page load event like this.

  if (!IsPostBack)
            {
                fillGridByALLBDetails();
            }

This is my business layer method to get the data.

     public DataTable getLibraryCatalogue()
{
    string myQuery1 = "EXEC SelectLibraryCatalogue";
    return new DataAccessLayer().ExecuteMyTable(myQuery1);
}

Sometimes my data grid loads a lots of data at once. I want to know how to achieve PAGING with this code. Any code example would be really great.

Thanks in advance.


Solution

  • Go through this detailed example

    http://www.aspsnippets.com/Articles/Paging-in-ASPNet-GridView-Example.aspx