user1390378
user1390378

Reputation: 433

How to refresh DataGrid?

I am working on Silverlight 5 and RIA Services for database operations. DataGrid showing data perfectly.

But when I delete a record and submit changes to database, database updating successfully, but DataGrid showing still old data. It is not refreshing.

I search on google and surprise to see that there is no simple answer and I am also surprise to see that microsoft has not provided this basic functionality in Silverlight.

Upvotes: 0

Views: 1838

Answers (2)

JacWo
JacWo

Reputation: 11

Have you tried to use an PagedCollectionView as ItemSource?

Something like:

DataGridMainTopic.ItemsSource = new PagedCollectionView(m_context.EntitySet);

or even:

DataGridMainTopic.ItemsSource = new PagedCollectionView(DataGridMainTopic.ItemsSource);

Upvotes: 0

Aharpe
Aharpe

Reputation: 112

It is not a good way by anymeans, but I have gotten around this by setting the DataGrid to null and the re-adding the data.

 System.Collections.IEnumerable temp = yourGrid.ItemsSource;
 yourGrid.ItemsSource = null;
 yourGrid.ItemsSource = temp;

I do not like doing it this way but it works and for my purposes I have not noticed any performance hits.

Edit: I guess this may not work with a delete though, but worth a try

Upvotes: 1

Related Questions