1. Create a new page and save it as gridviewsorted.aspx
2. Drag the gridview from the data asp.net controls onto the page, You will see:


3. Select new data source from the drop down choose data source> You will see:

4. Select access Database and Click Ok, you will see:

5. Type in the database name if in the root of the web site, or type in the folder/database name or browse and select the database and click next. . In this example I will be using northwind.mdb. You will see:

6. In this view first select the table or view(query) that you want to use. Then select the fields from the table/view that you want to display. In this example I will select the employee table and the fields EmployeeId. Lasname, firstname, title, and hiredate by putting a check mark in the field I want to display. You will see:

7. Now click order by: You will see:

8. Select Lastname in the sort by field, Select Firstname in the then by field you will see:

8. Click Ok you will see:

9. Click Next: you will see:
10. At this point when you view the page in browser the records will be sorted by last name and then first name.
11. To allow the user to sort on all of the fields selected. Select the grid view and then grid view task. You will see:

12. Put a check mark in the enable sorting.
13. Save the page and display in browser. You will see:

14. You can now click on the column heading to sort that column. You can only sort one column at a time.