Sorting , Paging and AutoGenerateColumns
The GridView control provides many built-in capabilities that allow the user to sort, update, delete, select, and page through items in the control.

Download Database
In this article I have used Microsoft's Pubs database for sample data. You can download it free from the following link.
DownloadBefore you start to generate GridView in your asp file, you should create a ConnectionString in your web.Config File. Double click the web.config file on the right hand side of the Visual Studio and add the following connectionstring code in that file.

Web.Config File
Each column in the GridView control is represented by a DataControlField object. By default, the AutoGenerateColumns property is set to true, You can also manually control which column fields appear in the GridView control by setting the AutoGenerateColumns property to false .
Sorting allows the user to sort the items in the GridView control with respect to a specific column by clicking on the column's header. To enable sorting, set the AllowSorting property to true.
Instead of displaying all the records in the data source at the same time, the GridView control can automatically break the records up into pages. To enable paging, set the AllowPaging property to true.
Also we can set how many rows we want to see in a page.
The following ASP.NET program shows how to enable sorting and paging in a GridView with a custom defined column fields.
Default.aspx
- ASP.NET Simple GridView
- ASP.NET GridView Editing
- ASP.NET GridView Delete
- DropDownList in GridView
- Create Gridview at runtime
- Gridview - Add, Edit and delete
- Gridview export to Excel
- Gridview export to CSV
- GridView summary on Footer
- Subtotal row in Gridview
- SubTotal and GrandTotal in GridView
- Create Gridview without database
- GridView from Stored Procedure
- How to create Gridview Popup Form
- How to create a Blank row in gridview
- Nested GridView in ASP.NET
- Freeze Gridview Header row, Scroll in GridView
- Auto Generate Row Number in GridView
- Image between GridView rows
- How to select a row in gridview
- Checkbox in ASP.NET GridView Control