/ Published in: C#
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
protected void grdVw_FileList_Sorting(object sender, GridViewSortEventArgs e) { GridSorting(e.SortExpression, grdVw_FileList); } private void GridSorting(string column, GridView grid) { // Session["column"] = ""; clear this after ever search/load string column_ASC = column + " ASC"; string column_DESC = column + " DESC"; DataTable dt = (DataTable)Session["fileList"]; if (Session["column"].ToString().ToUpper() == column_ASC.ToUpper()) { grid.DataSource = dv; grid.DataBind(); Session["column"] = column_DESC; } else { grid.DataSource = dv; grid.DataBind(); Session["column"] = column_ASC; } }