public SortDirection dir { get { if (ViewState["dirState"] == null) { ViewState["dirState"] = SortDirection.Ascending; } return (SortDirection)ViewState["dirState"]; } set { ViewState["dirState"] = value; } }
protected void gvEmployeeDetails_Sorting(object sender, GridViewSortEventArgs e) { string sortingDirection = string.Empty; if (dir == SortDirection.Ascending) { dir = SortDirection.Descending; sortingDirection = "Desc"; } else { dir = SortDirection.Ascending; sortingDirection = "Asc"; } DataView sortedView = new DataView(BindGrid()); sortedView.Sort = e.SortExpression + " " + sortingDirection; gvEmployeeDetails.DataSource = sortedView; gvEmployeeDetails.DataBind(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)