Apr 15, 2013

GridView In Sorting Asp.Net Ascending Descending

4/15/2013 03:58:00 AM

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();
            
        }

Written by

We are Creative Blogger Theme Wavers which provides user friendly, effective and easy to use themes. Each support has free and providing HD support screen casting.

0 comments:

Post a Comment

Recent Posts
Popular Articles

 

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

Back To Top