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. General Programming
  3. C#
  4. How to assign DataView to Datatable

How to assign DataView to Datatable

Scheduled Pinned Locked Moved C#
helpcsstutorial
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.
  • S Offline
    S Offline
    ss mmm
    wrote on last edited by
    #1

    I sort the datatable and hence store it in dataview. I use dataView.Sort. GridView.DataSource = SortedDataView; GridView.DataBind(); I get the sorted grid now. When I click edit, the sort goes off. So I try to store it in a cache Cache["AdminGrid"] = SortedDataView; Iam unable to retrieve it into a datatable again. DataTable dtData = (DataTable)Cache["AdminGrid"]; results in an error saying DataView cannot be converted into DataTable. Any help is appreciated.

    Thanks

    J 1 Reply Last reply
    0
    • S ss mmm

      I sort the datatable and hence store it in dataview. I use dataView.Sort. GridView.DataSource = SortedDataView; GridView.DataBind(); I get the sorted grid now. When I click edit, the sort goes off. So I try to store it in a cache Cache["AdminGrid"] = SortedDataView; Iam unable to retrieve it into a datatable again. DataTable dtData = (DataTable)Cache["AdminGrid"]; results in an error saying DataView cannot be converted into DataTable. Any help is appreciated.

      Thanks

      J Offline
      J Offline
      J 0
      wrote on last edited by
      #2

      DataViews have a Table property to return the DataTable that is associated with it. So you would get reference to the DataTable like... DataTable dtData = ((DataView) Cache["AdminGrid"]).Table;

      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