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. LINQ
  4. DataGridView does not update after linq insert. [modified]

DataGridView does not update after linq insert. [modified]

Scheduled Pinned Locked Moved LINQ
tutorialcsharpcssdatabaselinq
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.
  • A Offline
    A Offline
    andersus
    wrote on last edited by
    #1

    Hi, I have a master detail application like http://msdn.microsoft.com/en-us/vbasic/bb737879.aspx in vb with order and orderdetails, then I have a another table with orderdetail items that I want to pick from to the orderdetails with a addbutton. When i press the add button nothing happens in the grid, If I restart the application then the new orderdetail item shows up in the grid. How to do so the grid refreshes with the new orderdetail item? and how to remove orderdetail items from the grid. The sample project can be downloaded from my skydrive, it is a vs2008 project. http://cid-5bf7292cf8016af6.skydrive.live.com/self.aspx/.Public[^] /Stefan ---- test add button code example ----- Dim NewOrderRow = New OrderRow With {.OrderId = OrderIdTextBox.Text, .OrderRowDescription = "2ATest", .Quantity = 11, .Price = 22} Db.OrderRows.InsertOnSubmit(NewOrderRow) Me.Validate() Db.SubmitChanges() ----try to refresh grid---- Me.OrderRowsDataGridView.DataSource = "" Me.OrderBindingSource.DataSource = "" ' load data Dim AllOrder = From Order In Db.Orders _ Order By Order.OrderId _ Select Order Me.OrderBindingSource.DataSource = AllOrder OrderRowsDataGridView.DataSource = OrderRowsBindingSource

    modified on Saturday, May 9, 2009 4:04 AM

    S 1 Reply Last reply
    0
    • A andersus

      Hi, I have a master detail application like http://msdn.microsoft.com/en-us/vbasic/bb737879.aspx in vb with order and orderdetails, then I have a another table with orderdetail items that I want to pick from to the orderdetails with a addbutton. When i press the add button nothing happens in the grid, If I restart the application then the new orderdetail item shows up in the grid. How to do so the grid refreshes with the new orderdetail item? and how to remove orderdetail items from the grid. The sample project can be downloaded from my skydrive, it is a vs2008 project. http://cid-5bf7292cf8016af6.skydrive.live.com/self.aspx/.Public[^] /Stefan ---- test add button code example ----- Dim NewOrderRow = New OrderRow With {.OrderId = OrderIdTextBox.Text, .OrderRowDescription = "2ATest", .Quantity = 11, .Price = 22} Db.OrderRows.InsertOnSubmit(NewOrderRow) Me.Validate() Db.SubmitChanges() ----try to refresh grid---- Me.OrderRowsDataGridView.DataSource = "" Me.OrderBindingSource.DataSource = "" ' load data Dim AllOrder = From Order In Db.Orders _ Order By Order.OrderId _ Select Order Me.OrderBindingSource.DataSource = AllOrder OrderRowsDataGridView.DataSource = OrderRowsBindingSource

      modified on Saturday, May 9, 2009 4:04 AM

      S Offline
      S Offline
      SayreCC
      wrote on last edited by
      #2

      Hi, after youve save/insert a data you can call again your loading grid procedure.

      Hope this one can help. Thanks Hi, Please select Good Question if my answer are fit to your Question.

      A 1 Reply Last reply
      0
      • S SayreCC

        Hi, after youve save/insert a data you can call again your loading grid procedure.

        Hope this one can help. Thanks Hi, Please select Good Question if my answer are fit to your Question.

        A Offline
        A Offline
        andersus
        wrote on last edited by
        #3

        That is what I try to do as You can see in the code, it must be something with the master detail thing. If I have a single table and do the same thing it works. My project can be downloaded from my skydrive it is a vs2008 project. http://cid-5bf7292cf8016af6.skydrive.live.com/self.aspx/.Public[^]

        modified on Saturday, May 9, 2009 4:02 AM

        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