The ASP.Net GridView control property AllowSorting enables you to render the control with Sorting feature that can be handled at server side using VB.Net code logic easily. You can set the SortExpression property of BoundField or TemplateField of GridView control by specifying the name of the Data Column on which you want to map the Sorting function.
Sorting Event Used
The OnSorting event can be attached to the GridView control using VB.Net that enables you to apply the dynamic code to bind the data items in the specified sort order to the ASP.Net GridView control.
GridView Sorting Properties Used
1. AllowSorting (GridView)
2. SortExpression (BoundField or TemplateField)
The AllowSorting property accepts a boolean value as true/false that enables or disables the auto sorting feature of gridview control. The SortExpression property of BoundField or TemplateField accepts the value as name of the data field that you can pass to the sorting function that performs the sorting action based on that SortExpression.
Try the sample below to understand the functionality of VB.Net Sorting code applied to the ASP.Net GridView control: