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. Converting Dataview to a Datatable.

Converting Dataview to a Datatable.

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

    Hi, I have a datatable ParentTable that contains 100 records I created a Dataview that selects only UK users Dataview dvUK=ParentTable.DefaultView(); dvUK..RowFilter= "Country='UK'"; now in my dataiview dvUK have 30 records I want to copy all these 30 records to some other table(dtChildUK) that have same structures as the ParentTable DataTable dtChildUK=ParentTable.Clone(); How to copy all the 30 rows ( rows from dataview) to dtChildUK

    E S 2 Replies Last reply
    0
    • S salmonraju

      Hi, I have a datatable ParentTable that contains 100 records I created a Dataview that selects only UK users Dataview dvUK=ParentTable.DefaultView(); dvUK..RowFilter= "Country='UK'"; now in my dataiview dvUK have 30 records I want to copy all these 30 records to some other table(dtChildUK) that have same structures as the ParentTable DataTable dtChildUK=ParentTable.Clone(); How to copy all the 30 rows ( rows from dataview) to dtChildUK

      E Offline
      E Offline
      ElSpinos
      wrote on last edited by
      #2

      Try this after applying the filter to the DataView: foreach (DataRowView rowView in dvUK) { dtChildUK.Rows.Add(rowView.Row); }

      Fernando Mendes Senior .NET Developer, Architect

      S 1 Reply Last reply
      0
      • E ElSpinos

        Try this after applying the filter to the DataView: foreach (DataRowView rowView in dvUK) { dtChildUK.Rows.Add(rowView.Row); }

        Fernando Mendes Senior .NET Developer, Architect

        S Offline
        S Offline
        salmonraju
        wrote on last edited by
        #3

        Thank you

        1 Reply Last reply
        0
        • S salmonraju

          Hi, I have a datatable ParentTable that contains 100 records I created a Dataview that selects only UK users Dataview dvUK=ParentTable.DefaultView(); dvUK..RowFilter= "Country='UK'"; now in my dataiview dvUK have 30 records I want to copy all these 30 records to some other table(dtChildUK) that have same structures as the ParentTable DataTable dtChildUK=ParentTable.Clone(); How to copy all the 30 rows ( rows from dataview) to dtChildUK

          S Offline
          S Offline
          Syed Shahid Hussain
          wrote on last edited by
          #4

          Hello You can use only this method of dv: DataTable dtChildUK=dvUK.ToTable(); Simple and efficient. Be Happy :-D

          Syed Shahid Hussain

          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