Save Data to PropertyLinkCollection


I would like to save links to PropertyLinkCollection from code behind.

 PropertyLinkCollection propertyRelatedPages = pageClone.Property["RelatedPages"] as PropertyLinkCollection; // PageProperty

var linkCollectionClone = propertyRelatedPages.CreateWritableClone() as PropertyLinkCollection;
LinkItem item = new LinkItem();
var pageClone = pd.CreateWritableClone(); // Page to save PropertyLinkCollection to
/* Build the LinkItems here ....*/

linkCollectionClone.SaveData(linkCollectionClone.Value as PropertyDataCollection); // Here is the problem
// In the above line my linkCollectionClone.value  has all values but after casting to PropertyDataCollection the value turns null
//pd.Property["RelatedPages"].Value = linkCollectionClone.Value as PropertyDataCollection;
//Save Page

DataFactory.Instance.Save(pageClone, EPiServer.DataAccess.SaveAction.Publish);
How can I solve this?


Nov 14, 2011 16:22

Can't you just do: 

pageClone["RelatedPages"] = linkCollectionClone;

and then save the page?

Nov 14, 2011 16:35

"God damn it, I mean Allah damn it!"

How did I miss this thanks alot.

Nov 14, 2011 17:05
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.