Click here to Skip to main content
14,580,625 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hello everyone

I have sfDataGrid bound to ObservableCollection from generic repository with UinitOfWork. But the Grid does not refresh its UI when the datasource changes. I don't know what I am doing wrong.
Below is my code:

sfDataGrid1.DataSource = GetCustomerListViews;

public ObservableCollection<customerlistview> GetCustomerListViews => _unitOfWork.CustSups.GetCustomerListViews();

Is there a way to achieve two way binding with entityframework?

Thanks in advance for your assistance

What I have tried:

I have tried BindingSource and used different Collection type but have not been successful
Gerry Schmitz 29-Jun-20 10:57am
You've shown nothing that shows "how" the observable collection is "updated" or how / why you think EF is "aware" of your collection. EF works with "attached" entities; can't tell if yours are or are not.
Dave Kreskowiak 29-Jun-20 12:00pm
What do you mean by "when the datasource changes"? Are you saying you expect the data in the grid to update when the data in the database changes or when the data objects in the EF cache change?
noblepaulaziz 29-Jun-20 18:05pm
I mean when new record is added to the EF via Repo's AddRecmethod and SaveChanges is called to persist the new record to the database, the Grid does not update its UI to reflect the changes.

Also if any record is also modified via another a form, the grid UI is not updated either

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100