This is a migrated thread and some comments may be shown as answers.

Updating Bound ObservableCollection

2 Answers 213 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Guru
Top achievements
Rank 2
Guru asked on 01 Aug 2011, 05:44 PM
I am trying to make multiple changes to an observablecollection that is bound to a gridview.
Using linq to locate the items and then making changes.

It seems to work because I loop through in break mode and see it meeting the condition and setting the items Status value for the exact count of items that I am searching for, but I am not seeing changes reflect in gridview that has itemsource of the collection.

// grid.ItemSource = gridItemCollection (ObservableCollection<T>)
var itemsToUpdate = gridItemCollection.Where(item => item.Status.Equals(statusToChange));
foreach (var item in itemsToUpdate) item.Status = newStatus;

I assume since the collection is bound to the grid's ItemSource that it would update the grid automatically... does there need to be a manual update after the update takes place?

Is there a better approach for performance or clarity reasons?

2 Answers, 1 is accepted

Sort by
0
Guru
Top achievements
Rank 2
answered on 01 Aug 2011, 07:29 PM
Seems to work if I call grid.ReBind() after editting.
Is this what is best to do?
0
Accepted
Ivan Ivanov
Telerik team
answered on 02 Aug 2011, 02:49 PM
Hello Zack,

ObservableCollection<T> does not raise any events when its members have their properties changed. You should implement INotifyPropertyChanged on your business object class, in order to alarm the RadGridView of property modifications.

Best wishes,
Ivan Ivanov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
Tags
GridView
Asked by
Guru
Top achievements
Rank 2
Answers by
Guru
Top achievements
Rank 2
Ivan Ivanov
Telerik team
Share this question
or