SubmitChanges does not update a related datagridview

I have 3 related datagridviews on a Windows Forms page and I have a LINQ method to add/change records in the 3rd datagridview.

It works fine and the calling SubmitChanges works and records are added correctly to the SQL database but they are not shown on the datagridview - I have to exit the application and restart before I can see the new/changed records. I've tried various refresh options but without successs.

I also tried calling what I do in the Form Load i.e.DayBindingSource.DataSource = db.Days immediately after SubmitChanges to reload all of the datagridiews but that has no effect either.

Any guidance would be welcomed!

[1129 byte] By [Craigton] at [2008-1-8]
# 1

This looks like it's related to my problem (see: http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1968247&SiteID=1).

Table<T> implements IListSource, IListSource.GetList() creates a separate IList for binding, which doesn't track the changes of the table, only writes back it's own changes.

The best solution I've found so far is to manually sync the related BindingList via events and partial methods. You can alternatively try DayBindingSource.DataSource = db.Days.GetNewBindingList()

BachratyGergely at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,ADO.NET Orcas...
# 2

Hi Bachraty,

Thanks for this but DayBindingSource.DataSource = db.Days.GetNewBindingList() didn't refresh my datagrid. I've gone back to Datasets and TableAdapters!

Craigton at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,ADO.NET Orcas...
# 3

I can help you, I have no problem in refreshing my DatagridView, I am using VS2008 Beta2, what VS you are using.

Thanks

http://www.ifuturesoft.com

BrianIlyas at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,ADO.NET Orcas...
# 4
Thanks for the offer - I'm also using VS2008 Beta 2
Craigton at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,ADO.NET Orcas...
# 5

Hi Brian ,

What was your solution to having a (3rd) related datagridview updated?

Craigton at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,ADO.NET Orcas...
# 6
If you want to see the latests database state in your ui bound objects you are going to need to create a new DataContext, requery and rebind. One of the roles of the DataContext is to keep you isolated from database changes.
MattWarren-MSFT at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,ADO.NET Orcas...
# 7

Hi Matt,

Thanks for this but I'm still lost as to why it works OK for table 1 and 2 but not for table 3? I can make changes in either of datagrids 1 or 2 and those changes are reflected in both the physical tables and the associated datagrids.

Also, because the datagrid that does not reflect changes to datagrid 2 is the 3rd in the relationship, I cannot see how to create a LINQ query that will completely synchronise with the other 2 datagrids/tables.

Thanks in advance.

Craigton at 2007-10-2 > top of Msdn Tech,Visual Studio Orcas,ADO.NET Orcas...

Visual Studio Orcas

Site Classified