I create a GridView programatically and bind it to a DataView. Works fine until it comes to sorting. Clicking those columns that i have set to be sortable makes
my event handler fire only every second time. Sorting becomes correct, but it always needs two clicks to be correct.
I create my GridView like this:
GridView gw = new GridView();
gw.AutoGenerateColumns = false;
gw.GridLines = GridLines.Horizontal;
gw.AllowSorting = true;
gw.Sorting += new GridViewSortEventHandler(Sorting);
The event handler:
public void Sorting(object sender, GridViewSortEventArgs e)
ViewState["sortExpression"] = e.SortExpression;
if (GridViewSortDirection == SortDirection.Ascending)
GridViewSortDirection = SortDirection.Descending;
GridViewSortDirection = SortDirection.Ascending;
BuildRanking sorts the dataview and binds it to the gridview.
Any help out there?