On 8/14/11 12:25 PM, Anders Eriksson wrote:
[...]
Hmmm, I have read somewhere that a list<T> has some problems when using
it as a binding source.
It's probably something I have misinterpreted....
It depends on what behavior you expect. List<T> does not offer
notifications for changes, so it's not full-featured when used as a
binding source. There is a BindingList<T> that is better for that
purpose.
Now when you mention it, this is what i read!
For many scenarios, the bound list isn't expected to change and a plain
List<T> is fine.
OK, The more you know the more choices you have to make...
Thank you very much!
But you can make the object a smart object in the List<T>, and you can
query for any object that is dirty by using Linq to determine if any
object in the List<T> is dirty.
After the binding of a List<T> and you need to change a property of the
object, you can do it off of the grid's index and address the object's
property directly.
<
http://www.dailycoding.com/Posts/maintaining_dirty_and_new_state_of_objects.aspx>
If you send the List<T> to a Business or Data Access layer or you
persist data by other means, then you know which persist logic to use
for the object based on the object's state.
1) IsNew and IsDirty -- insert
2) !IsNew and IsDirty - update
3) IsDelete -- delete