Return to Snippet

Revision: 28112
at July 1, 2010 01:47 by mpcircuitry


Initial Code
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())
            {
                DataView dv = new DataView(dt, "", column_DESC, DataViewRowState.CurrentRows);
                grid.DataSource = dv;
                grid.DataBind();
                Session["column"] = column_DESC;
            }
            else
            {
                DataView dv = new DataView(dt, "", column_ASC, DataViewRowState.CurrentRows);
                grid.DataSource = dv;
                grid.DataBind();
                Session["column"] = column_ASC;
            }

        }

Initial URL

                                

Initial Description

                                

Initial Title
Sorting Gridview Control ASP.NET

Initial Tags
c, Net, aspnet

Initial Language
C#