AI OnAI Off
First you should use Type = PropertyDataType.PageType.
Second, could you identify which page(s) are throwing the exception? What Page Type they are and what Page Type Class they should be and whether AsTyped() or TryAsTyped() is trying to cast them to another Page Type Class?
Hi,
I am using episerver 6 r 2 cms.
I am trying to fetch all my news pages in my site using the following code. I am getting an error - unable to cast pagedatat to news pagte type. I heard, it is a bug in episever 6 r2 cms, some people suggested to use AsTyped() but I tried TryAsTyped() didn't work.
Any help would be appreciated !!
var criterias = new PropertyCriteriaCollection();
var criteria = new PropertyCriteria
{
Condition = CompareCondition.Equal,
Name = "PageTypeName",
Type = PropertyDataType.String,
Value = "NyhetsSida",
Required = true
};
criterias.Add(criteria);
var newsTemp = DataFactory.Instance.FindPagesWithCriteria(new PageRepository().GetNewsListPage(), criterias, EPiServer.Security.AccessLevel.Read).TryAsTyped();