sort
-
how do i sort my gridview????
-
how do i sort my gridview????
Using
AllowSorting="True"
. Please search in google, you will get many answer for that.Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.
-
how do i sort my gridview????
Write following code in your grid sorting event.. DataTable m_DataTable = (DataTable)(Give your gridview data source here) if (m_DataTable != null) { DataView m_DataView = new DataView(m_DataTable); m_DataView.Sort = e.SortExpression + " " + ("ASC" or "DESC"); gridview.DataSource = m_DataView; gridview.DataBind(); }
-
Write following code in your grid sorting event.. DataTable m_DataTable = (DataTable)(Give your gridview data source here) if (m_DataTable != null) { DataView m_DataView = new DataView(m_DataTable); m_DataView.Sort = e.SortExpression + " " + ("ASC" or "DESC"); gridview.DataSource = m_DataView; gridview.DataBind(); }
i have the following DataTable dtBasel = Session["TaskTable"] as DataTable; if (dtBasel != null) { dtBasel.DefaultView.Sort = e.SortExpression + "" + sGetSortDirection(e.SortExpression); gvtest.DataSource = Session["TaskTable"]; gvtest.DataBind(); } for the grdview_sorting event and private string sGetSortDirection(string sColumn) { string sSortDirection = "ASC"; string sSortExpression = ViewState["SortExpression"] as string; if (sSortExpression != null) { if (sSortExpression == sColumn) { string sLastDirection = ViewState["SortExpression"] as string; if ((sLastDirection != null) && (sLastDirection == "ASC")) { sSortDirection = "DESC"; } } } ViewState["SortExpression"] = sSortDirection; ViewState["SortExpression"] = sColumn; Bindgvtest(); return sSortDirection; } but it only sort 1 column, and i need it to sort any column i press ... ????
-
i have the following DataTable dtBasel = Session["TaskTable"] as DataTable; if (dtBasel != null) { dtBasel.DefaultView.Sort = e.SortExpression + "" + sGetSortDirection(e.SortExpression); gvtest.DataSource = Session["TaskTable"]; gvtest.DataBind(); } for the grdview_sorting event and private string sGetSortDirection(string sColumn) { string sSortDirection = "ASC"; string sSortExpression = ViewState["SortExpression"] as string; if (sSortExpression != null) { if (sSortExpression == sColumn) { string sLastDirection = ViewState["SortExpression"] as string; if ((sLastDirection != null) && (sLastDirection == "ASC")) { sSortDirection = "DESC"; } } } ViewState["SortExpression"] = sSortDirection; ViewState["SortExpression"] = sColumn; Bindgvtest(); return sSortDirection; } but it only sort 1 column, and i need it to sort any column i press ... ????
-
how do i sort my gridview????