Looping through all Component Presentations on a Page
If the Component Presentations on a Page are not assembled at visit time using a query, the Page contains a list of Component Presentations (that is, pairs consisting of a Component and its accompanying Component Template). Typically, you would want to loop through this list of Component Presentations.
static void IteratingComponentPresentations(CoreServiceClient client)
{
const string pageUri = "tcm:2-372-64";
PageData page = (PageData)client.Read(pageUri, null);
Console.WriteLine("Component Presentations of Page {0} ({1})", page.Title, page.Id);
foreach (ComponentPresentationData componentPresentation in page.ComponentPresentations)
{
Console.WriteLine("Component {0} with Component Template {1}", componentPresentation.Component.IdRef, componentPresentation.ComponentTemplate.IdRef);
}
}