Try our conversational search powered by Generative AI!

Error in retreiving Property.



I am getting pages of particular pagetype as PageDataCollection using findpageswithcriteria.

Now i want the value of property in a for loop like this but i am getting error

PageDataCollection  _PageItems = DataFactory.Instance.FindPagesWithCriteria(PageReference.RootPage, criterias);
                foreach (var partnerInfo in _PageItems)
                    PropertyData pd = partnerInfo.Property["PartnerName"];                
                    if (pd != null && pd.IsNull == false)
                          string partner = pd.Value.ToString();                   

Any body can help me to solve this issue.

Jan 29, 2011 15:03

What is the error?

Jan 29, 2011 15:41

In pd.Value i am getting null not the actual value form page.

Jan 31, 2011 4:59

Are you sure every page has a property called "PartnerName"?  If a page doesn't have this property, pd will be null.

If it DOES have this property, but it doesn't have a value entered, pd.Value will be null, which means your ToString() call will fail.

Summary --

  • pd will be null when the page doesn't have a property called "PartnerName"
  • pd.Value will be null when it does have a property, but no value has been entered for it.
Jan 31, 2011 5:28


Ok,I got the reason for this i.e pages are not published.If i publish pages than its working fine.

Could we get only Published pages using FindPagesWithCriteria?

Jan 31, 2011 5:50

Use FilterPublish or FilterForVisitor (EPiServer.Filters namespace) to filter your PageDataCollection before the loop.

Jan 31, 2011 6:56
* 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.