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. ASP.NET
  4. Datagrid Sorting using DataSource

Datagrid Sorting using DataSource

Scheduled Pinned Locked Moved ASP.NET
databasealgorithmsquestion
2 Posts 2 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.
  • A Offline
    A Offline
    AZBugsBunny
    wrote on last edited by
    #1

    I would like to know if there is anyway we can do a sorting of the Datagrid columns by retreiving the datasource and doing an order by on that Datasource instead of having to make a call to the DB that appends the appropriate ORDER BY clause to the SQL that changes the dataset returned back to the datagrid. Basically I wnat to figure out if it is possible to implement Datagrid sorting without having to perform a Database hit every time a sort operation is done. Any ideas?

    A 1 Reply Last reply
    0
    • A AZBugsBunny

      I would like to know if there is anyway we can do a sorting of the Datagrid columns by retreiving the datasource and doing an order by on that Datasource instead of having to make a call to the DB that appends the appropriate ORDER BY clause to the SQL that changes the dataset returned back to the datagrid. Basically I wnat to figure out if it is possible to implement Datagrid sorting without having to perform a Database hit every time a sort operation is done. Any ideas?

      A Offline
      A Offline
      Angel Reyes
      wrote on last edited by
      #2

      One thing that you can do is to save the dataset to session (this will prevent the trip to the database) and create a Dataview that is bound to that dataset. The DataGrid is then bound to the DataView. The code would look something like this... System.Data.DataSet ds = new System.Data.DataSet(); System.Data.DataView dv = new System.Data.DataView(); dv.Table = ds.Tables[0]; dv.Sort = "FirtName Asc";

      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