Here, we describe how to paging and sorting
records in GridView using SqlDataSource. In this article we create connection
string and create connection with database without write a single code.
Step 1:
Go to the design view of aspx page and drag a
GridView control from toolbox on the form. Set AutoFormate= Colorful to
display colorful GridView.

Figure1.
Step 2:
Now click on smart tag of GridView and choose
new datasource.

Figure2
Step 3:
Now select a database.

Figure3
Now click on OK Button.

Figure4
Step 4:
Now click on the test connection Button. and
give server name user name and password and select database from the Dropdown
list.

Figure5
Now click on the OK Button. Connection string
will be display.

Figure6
Now click on the next Button.

Figure7
Now select a table from the drop down list. and
click on the next Button.

Figure8
At the end click on the Finish Button.
After that click on the smart tag of GridView
and select paging and sorting.

Figure9
Set page size property=4
Now build and run the application.

Figure10
Test it click on the header title to sort
record in ascending and descending order.