In Markup set
GridView
attributes as given bellow
AllowSorting="True"
OnSorting="gridView_Sorting"
For each column Header Template do the following
<asp:TemplateField SortExpression="YourFieldName">
<HeaderTemplate>
<asp:LinkButton ID="linkbutton" runat="server" Width="100%" CommandName="Sort" CommandArgument=" YourFieldName" />
</HeaderTemplate>
<ItemTemplate></ItemTemplate?
</asp:TemplateField>
And
In code behind
gridview_Sorting
event handler
Use
e.SortExpression
and
e.SortDirection
to further implement the logic.
HTH