Home Page
"Join my free Amazing ASP.NET newsletter"
It's safe and easy to signup. You get:
  • Notified anytime a new article comes out
  • Technical step-by-step tutorials on all important ASP.NET topics
  • Expert guidance so you can reach unlimited ASP.NET success
  • Important ASP.NET news updates
Enter your Email

Click here to download the source code for this lesson.

The SqlDataSource server control can make your GridView control easily allow data paging for the end user of your web application without writing any C# code.  For example, if you are showing the results of a query on a web page and you want the user to be able to look at one page of data at a time.  This of course applies to situations where you have several rows of return data and one screen is not sufficient to display all of the results.  You can define how many rows are shown in a page, but by default it is 10.  If more rows are in your DataSet than your page size, .NET will show a hyperlink at the bottom of your GridView that allows the user to view page 2, 3, etc.

First, you should have established a binding between the GridView control and an SqlDataSource control on your web form.  Refer to the prior lesson Retrieving database data with the ASP.NET SqlDataSource and GridView controls to learn how to do that if you haven’t already.

Next, set the AllowPaging property of your GridView control to True.  Then set the PageSize property to how many records you want to show on each page.  Again, the default is 10.  That is all you have to do.  Pretty simple huh?

Click here to watch an example video where I setup paging in my GridView control.

Did you enjoy this article? Join my free Amazing ASP.NET newsletter.
It's safe and easy to signup. Unleash your unlimited web programming potential. You get:
  • Notified anytime a new article comes out
  • Technical step-by-step tutorials on all important ASP.NET topics
  • Expert guidance so you can reach unlimited ASP.NET success
  • Important ASP.NET news updates
Enter your Email

1 Comment »

  1. Thanks… Any suggestion or idea how to make a due date reminder?

    Comment by Lynn — August 27, 2009 @ 2:12 am

RSS feed for comments on this post. TrackBack URL

Leave a comment