Hi
Store your sort direction in a viewStateVariable.
Save the last direction once you're completed sorting. I've used three states below: ASC, DESC, unsorted:
(In "grdvwdesignmaster_Sorting" change
"dataView.Sort = e.SortExpression + " " + ConvertSortDir(e.SortDirection);
"
to:
if (GridViewSortDirection.Length > 0)
{
dataView.Sort = e.SortExpression + " " + GridViewSortDirection;
}
ChangeSortDirection();
ViewState property & function:
private string GridViewSortDirection
{
get { return ViewState["SortDirection"] as string ?? "ASC"; }set { ViewState["SortDirection"] = value; }
}
private string ChangeSortDirection()
{
switch (GridViewSortDirection)
{
case "ASC":
GridViewSortDirection =
"DESC";break;
case "DESC":GridViewSortDirection = "";
break;default:
GridViewSortDirection =
"ASC";break;
}
return GridViewSortDirection;
}
}
private string GridViewSortDirection
{
get { return ViewState["SortDirection"] as string ?? "ASC"; }
set { ViewState["SortDirection"] = value; }
}