About Link Collection Property in EpiServer 5 R2

Vote:
 

Dear All,

Has anyone created the Link Collection Property dynamically through code behind. My problem is, I need to create Epi-Server Pages Dynamically, which also contains a link collection property and i need to popuplate them dynamically on the fly.

 Please if some one help and send me the code.

Thanks in advance.
Tony

 

#33278
Oct 07, 2009 0:37
Vote:
 

I assume (havn't tested it) that this code would do the trick:

PageData newPage = EPiServer.DataFactory.Instance.GetDefaultPageData(parentId, "pageTypeWithLinkColProperty"); 

LinkItemCollection linkCol = new EPiServer.SpecializedProperties.LinkItemCollection();

LinkItem item = new LinkItem();
item.Href = page.LinkURL;
item.Text = page.PageName;
item.Title = page.PageName;
item.Target = "_self";
linkCol.Add(item);

newPage.Property["MyLinkItemCol"].Value = linkCol;

// set other required property values and save page

#33290
Oct 07, 2009 10:42