Accessing PageData on PageList

Vote:
 

I have tried to get the first PageData on an EPiServer databound PageList through code.  When trying to access the datasource for the PageList (<PageListControl>.DataSource as PageDataCollection) I am being return 'null'.

Pages exist and are being returned through the HTML InnerTemplate.

Any ideas?

#50175
Apr 14, 2011 20:07
Vote:
 

If you are getting the pages by setting the PageLink or PageLinkProperty properties of the control, the DataSource property is null. DataSource is used if you have an enumerable collection of PageDatas that you want to display, not to get the pages the control finds itself using the PageLink.

So if you want to find the first page displayed, you could simply collect the pages yourself in code and set the DataSource property of the control to that collection instead of using PageLink. Because you have the collection you can also easily find the first page.

If you for some reason want to stay with the PageLink auto-binding solution, you can attach an event handler to the Filter event and check in there which page is the first in the collection.

#50180
Apr 15, 2011 8:34
Vote:
 

Many thanks Magnus

#50183
Apr 15, 2011 10:11
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.