Login

How do I add existing pages to a PageDataCollection?

Versions: n/a, FAQ number: 61, Old FAQ number: 979

Q: How do I add existing pages to a PageDataCollection?

A: A common mistake when trying to add an existing page to a PageDataCollection is to create a new PageData object and initialize it with a PageReference, for example:

PageDataCollection pages = new PageDataCollection();
PageReference pageLink = new PageReference(4711);
pages.Add(new PageData(pageLink));

The result is an empty page with the page ID 4711. Any existing page with ID 4711 will not be loaded.

The right way to do it is shown by the following example:

PageDataCollection pages = new PageDataCollection();
PageReference pageLink = new PageReference(4711);
pages.Add(Global.EPDataFactory.GetPage(pageLink));

EPiTrace logger