LINQ2SQL - Binding result to a grid - want changes to be reflected without re-binding?

Posted by Isaac on Stack Overflow See other posts from Stack Overflow or by Isaac
Published on 2010-04-02T18:04:36Z Indexed on 2010/04/02 18:13 UTC
Read the original article Hit count: 555

Hello,

I have a grid (DevExpress XtraGrid, if that matters) which is bound to a LINQ to SQL Entity property.

gridItems.DataSource = purchaseOrder.PendingItemsGrouped;

Well, the grid is being displayed properly,and I can see the purchase items that are pending. The problem arises when purchaseOrder.PendingItemsGrouped gets changed ... once that happens, the grid does not reflect the changes.

The exact procedure is as following: The user selects a row from the grid, inserts a serial number on a specific textbox, and then hits enter effectively receiving this item from the purchase order, and inserting it into stock.

inventoryWorker.AddItemToStock( userSelectedItem, serialNumber );

The item gets properly inserted to the inventory, but the grid still shows the item as if it is still awaiting it to be received.

How do I solve this problem? Do I really need to re-bind the grid so the changes can be reflected?

I even tried instead of:

gridItems.DataSource = ...;

This:

gridItems.DataBindings.Add( new Binding( "DataSource", purchase, "PendingItemsGrouped" ) );

But couldn't solve the problem. Thank you very much for your time,

Isaac.

OBS: Re-Binding the Grid works, but my question is ... is that even the proper way of doing things? I feel like I'm miles off the right track.

© Stack Overflow or respective owner

Related posts about linq-to-sql

Related posts about windows-forms