When working with the DataGrid component it’s often important to stay on top of performance and to provide an easy to use interface. Sometimes a lot of work and effort goes into making a great DataGrid display and layout but some of the details get lost along the way.
There are 2 features that are built into the DataGrid which can help make your end users lives a little easier when working with larger amounts of data. These 2 features are paging and sorting. Paging refers to taking a large set of data and paging it across multiple pages instead of presenting all of the rows at once, and sorting of course refers to allowing the user to sort the data by certain columns. Both provide a way for your end user to find the data they are searching for a little easier.
There does come certain overhead with using these features, but this is usually the price you pay for providing a richer user interface. There are a couple different ways to provide these features as well. We will look at the fastest and easiest way to implement both.
In this tutorial we will implement a simple ASP.NET sample application which displays a listing of products from the sample Northwind SQL database. We will implement the sample application in 3 stages. The first stage we will build the connection and get our DataGrid to simply display a listing of products.
In the second stage we will add sorting to the DataGrid so that you can click on certain column headings, and in the third stage we will add paging to the DataGrid using the default paging features without customization.
Note: Visual Studio .NET running ASP.NET ver 1.x is required for this tutorial. Access to a version of SQL Server is also required as we will use the sample Northwind SQL database to connect to. Both VB.NET and C# code samples will be provided