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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. Sorting

Sorting

Scheduled Pinned Locked Moved ASP.NET
algorithmshelp
3 Posts 3 Posters 0 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.
  • M Offline
    M Offline
    musnet2007
    wrote on last edited by
    #1

    i am using the below sample code for sort in repeater, it is sorting only in asc order, now i want to sort both direction, i am using defaultview.sort, using the same function can anyone help me Thankz connection open() strSql = "select fiel1,fie2 from tablename order by columname or (Request.QueryString("val"))" Dim da As New OleDbDataAdapter(strSql, connection) Dim ds As New DataSet da.Fill(ds) If Request.QueryString("val") = "" Then repeater.DataSource = ds.Tables(0) Else ds.Tables(0).DefaultView.Sort = Request.QueryString("val") repeater.DataSource = ds.Tables(0).DefaultView repeater.DataBind() End If connectionclose()

    A E 2 Replies Last reply
    0
    • M musnet2007

      i am using the below sample code for sort in repeater, it is sorting only in asc order, now i want to sort both direction, i am using defaultview.sort, using the same function can anyone help me Thankz connection open() strSql = "select fiel1,fie2 from tablename order by columname or (Request.QueryString("val"))" Dim da As New OleDbDataAdapter(strSql, connection) Dim ds As New DataSet da.Fill(ds) If Request.QueryString("val") = "" Then repeater.DataSource = ds.Tables(0) Else ds.Tables(0).DefaultView.Sort = Request.QueryString("val") repeater.DataSource = ds.Tables(0).DefaultView repeater.DataBind() End If connectionclose()

      A Offline
      A Offline
      Ajai Chaudhary
      wrote on last edited by
      #2

      Use your sql query in the followign manner it will sort the records in desecding order.

      order by columname desc

      The desc keyword followed by the column will arange the data into desecding order with regards Yogesh Agarwal

      1 Reply Last reply
      0
      • M musnet2007

        i am using the below sample code for sort in repeater, it is sorting only in asc order, now i want to sort both direction, i am using defaultview.sort, using the same function can anyone help me Thankz connection open() strSql = "select fiel1,fie2 from tablename order by columname or (Request.QueryString("val"))" Dim da As New OleDbDataAdapter(strSql, connection) Dim ds As New DataSet da.Fill(ds) If Request.QueryString("val") = "" Then repeater.DataSource = ds.Tables(0) Else ds.Tables(0).DefaultView.Sort = Request.QueryString("val") repeater.DataSource = ds.Tables(0).DefaultView repeater.DataBind() End If connectionclose()

        E Offline
        E Offline
        eggsovereasy
        wrote on last edited by
        #3

        ds.Tables[0].DefaultView.Sort = Request.QueryString("val") + "desc"; But you will probably want to add someway to toggle between asc and desc.

        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