Sorting a ASP.NET 4.0 (c#) ListView

lutuy

New Member
I have a ListView -- bound from a datatable -- containing several pages of chronological items.I would like to be able to sort them in ascending and descending order.In my \[code\]<layouttemplate>\[/code\] I have the following:\[code\]<asp:linkbutton runat="server" id="SortbyYear" commandname="Sort" commandargument="Year">Year</asp:linkbutton>\[/code\]When I click on that, I get an error from the pageRequestManager that onsorting is not handled.So I added the following to my \[code\]<asp:listview ... >\[/code\]:\[code\]onsorting="HistoryList_Sorting"\[/code\]What do I actually put in that method in the code behind to get sorting to work? I am just try to toggle the column "Year" back and forth between ascending and descending.\[code\]protected void HistoryList_Sorting(object sender, ListviewSortEventArgs e){ // WHAT GOES HERE???}\[/code\]
 
Back
Top