Showing posts with label Sorting in Grid view. Show all posts
Showing posts with label Sorting in Grid view. Show all posts

Apr 15, 2013

GridView In Sorting Asp.Net Ascending Descending

OnSorting="Doc_Sorting"

 protected void Doc_Sorting(object sender, GridViewSortEventArgs e)
        {
            
            DataTable objdt;
            DataView dv;
            objdt = new DataTable();
            DB Access = new DB();
            string Sql = " select CustomerID,Shipname from orders";
            DataSet ds = Access.GetDataSet(Sql);
            objdt = ds.Tables[0];
            dv = new DataView(objdt);
            if (ViewState["DocSortDirection"] != null)
            {
                if ((SortDirection)ViewState["DocSortDirection"] == SortDirection.Ascending)
                {
                    dv.Sort = e.SortExpression + " ASC";
                    ViewState["DocSortDirection"] = SortDirection.Descending;
                }
                else
                {
                    dv.Sort = e.SortExpression + " DESC";
                    ViewState["DocSortDirection"] = SortDirection.Ascending;
                }
            }
            else
            {
                dv.Sort = e.SortExpression + " ASC";
                ViewState["DocSortDirection"] = SortDirection.Descending;
            }
            GV_Employee.DataSource = dv;
            GV_Employee.DataBind();
            
        }
Recent Posts
Popular Articles

 

© 2013 MUNISH ORACLE DBA& .Net Developer. All rights resevered. Designed by Templateism

Back To Top