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. Update DataTable with DataGridView

Update DataTable with DataGridView

Scheduled Pinned Locked Moved C#
questionannouncement
3 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.
  • M Offline
    M Offline
    myNameIsRon
    wrote on last edited by
    #1

    Hi, I have a DataTable bound to a DataGridView with this code: dataGridView1.DataSource = myDT_Items; I'm updating a DataGridView with this code: dgvRow.Cells["ItemSize"].Value = 55; Now I want the DataTable to reflect the changes made to the DataGridView. Currently I'm using: myDT_Items.AcceptChanges(); Q: Is there another way to Synchronize DataTable with DataGridView when changes are made to the DataGridView? Thanks, Ron

    A 1 Reply Last reply
    0
    • M myNameIsRon

      Hi, I have a DataTable bound to a DataGridView with this code: dataGridView1.DataSource = myDT_Items; I'm updating a DataGridView with this code: dgvRow.Cells["ItemSize"].Value = 55; Now I want the DataTable to reflect the changes made to the DataGridView. Currently I'm using: myDT_Items.AcceptChanges(); Q: Is there another way to Synchronize DataTable with DataGridView when changes are made to the DataGridView? Thanks, Ron

      A Offline
      A Offline
      AhsanS
      wrote on last edited by
      #2

      Why are you using the synchronization? Are you using datagridview some where else as well? If not then do the changes directly in the datatable.

      Ahsan Ullah Senior Software Engineer

      M 1 Reply Last reply
      0
      • A AhsanS

        Why are you using the synchronization? Are you using datagridview some where else as well? If not then do the changes directly in the datatable.

        Ahsan Ullah Senior Software Engineer

        M Offline
        M Offline
        myNameIsRon
        wrote on last edited by
        #3

        Thanks Ahsan, Yes, I could update the DataTable directly, but then I'd have use something like dataTable.Rows.Find() to correlate with the selected row in DataGridView. Do you know of a better way to find the DataTable row based on the selected DataGridView Row? Even if I do go the route of updating the DataTable directly, I'm always interested in learning more. I'm basically wanting to know the best way to sync the DataTable with the DataGridView if the DataGridView is edited. Ron

        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