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