I really like the new PropertyList in EPiServer. There is a great blog post by Per Magne Skuseth on how to use it with simple classes.
I used Per's code as an example but I ended up with some strange behaviour (yeah yeah, it's beta code I know)
In the UI I can add and remove entries to the list and then publish the changes, this works fine. However when I try to modify entries in the list, changes are not detected. (Try changing the age of a person)
Same goes for modifying entries from code.
var clone = currentPage.CreateWritableClone() as StartPage;
clone.Contacts.Age = 150; //Very old guy
_contentRepository.Save(clone, SaveAction.Publish, AccessLevel.NoAccess);
No change is stored in the database, nothing is published.
Debugging learned me that IsModified on the PropertyList is always false. How do I get my changes detected?
In the latest update of Episerver CMS modifications of a PropertyList entry in the edit UI are detected, so I can publish my changes there
However when I change a PropertyList entry from code changes are not detected.
Is this a known issue? Am I doing something wrong?
I think that you need to ass the whole list, not just the property of the list. So instead of clone.Contacts.Age = 150; you need to execute:
clone.Contacts.Age = 150;
clone.Contacts = clone.Contacts;
I think that mark property as IsModified should also work:
clone.Property["Contacts"].IsModified = true;
Thanks a million Grzegorz!!
did the job!