November Happy Hour will be moved to Thursday December 5th.

Error in retreiving Property.

Vote:
 

Hello

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.

#47469
Jan 29, 2011 15:03
Vote:
 

What is the error?

#47470
Jan 29, 2011 15:41
Vote:
 

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

#47484
Jan 31, 2011 4:59
Vote:
 

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.
#47485
Jan 31, 2011 5:28
Vote:
 

Thanks

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?

#47486
Jan 31, 2011 5:50
Vote:
 

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

#47487
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.