protected override void OnSorting(GridViewSortEventArgs e)
{
base.OnSorting(e);
if (e.Cancel) return;
if (e.SortExpression == _lastexpression)
{
_ascending = !_ascending;
}
else
{
_ascending = true;
_lastexpression = e.SortExpression;
}
if (DataSource is IDomainCollection)
{
var source = (IDomainCollection) DataSource;
source.Sort(e.SortExpression, (_ascending) ? SortOrder.Ascending : SortOrder.Descending);
DataSource = source;
}
DataBind();
}