gormit
gormit

Reputation: 807

Sorting a gridview that has paging enabled

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?

Upvotes: 2

Views: 149

Answers (1)

Muhammad Akhtar
Muhammad Akhtar

Reputation: 52241

If you use a list object as DataSource then your sorting function will not work.

You can use a DataTable as DataSource to 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?

Upvotes: 2

Related Questions