I have a list binding on a gridview.
HistoryGrid.DataSource = objGrid;
HistoryGrid.DataBind();
AllowSorting="true" AllowPaging="True"
<asp:BoundField HeaderText="hits" DataField="numberOfHits"
SortExpression="numberOfHits" ItemStyle-HorizontalAlign="Center" />
This doesn`t work. What else do I need?
If you use a
list object as DataSourcethen your sorting function will not work.You can use a
DataTable as DataSourceto your Gridview and then it will work.You can get more ideas from this thread: How to convert a GridView to DataTable and sort the DataTable?