Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. sort

sort

Scheduled Pinned Locked Moved Web Development
question
6 Posts 4 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    baselanfouqa
    wrote on last edited by
    #1

    how do i sort my gridview????

    A R C 3 Replies Last reply
    0
    • B baselanfouqa

      how do i sort my gridview????

      A Offline
      A Offline
      Abhijit Jana
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0
      • B baselanfouqa

        how do i sort my gridview????

        R Offline
        R Offline
        raghu g
        wrote on last edited by
        #3

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

        B 1 Reply Last reply
        0
        • R raghu g

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

          B Offline
          B Offline
          baselanfouqa
          wrote on last edited by
          #4

          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 ... ????

          R 1 Reply Last reply
          0
          • B baselanfouqa

            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 ... ????

            R Offline
            R Offline
            raghu g
            wrote on last edited by
            #5

            use SortExpression in every column of grid view that you want to sort.this will solve the problem...

            1 Reply Last reply
            0
            • B baselanfouqa

              how do i sort my gridview????

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              Consider the ASP.NET forum for ASP.NET questions in future...

              Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups