GridView control from ASP.NET 2.0 like this one is widely used:
<asp:GridViewrunat="server"ID="gridPersons"AutoGenerateColumns="false"AllowSorting="true"OnSorting="gridPersons_Sorting"><Columns><asp:BoundFieldHeaderText="First name"DataField="FirstName"SortExpression="FirstName"/><asp:BoundFieldHeaderText="Last name"DataField="LastName"SortExpression="LastName"/></Columns></asp:GridView>
protected void gridPersons_Sorting(object sender, GridViewSortEventArgs e) { string sortExpression = e.SortExpression; }
Â
However, it has one limitation: the sorting event argument GridViewSortEventArg is based on string values from markup, which means it cannot be used in programmatic sorting using LINQ. Â This article will describe how to convert a string argument to a sorting expression to be used in LINQ.
Read the rest of the tutorial here:Â http://www.codeproject.com/Articles/246361/Handle-GridView-OnSorting-using-LINQ