More in this section

Forums / Developing with Sitefinity / getpage sorted data based on parent guid?????????????????????????????????????????????????

getpage sorted data based on parent guid?????????????????????????????????????????????????

3 posts, 0 answered
  1. sam
    sam avatar
    102 posts
    31 Jan 2008
    27 Mar 2008
    Link to this post

    I am wanting to get sorted child pages based on a parent guid.

    There is an overload:

    But this doesn't take parent id.

    In my implementation
    I have a business logic layer in a separate .net 3.5 project which has:

    public static IList<ICmsPage> GetChildren(string pageName)
                IList<ICmsPage> list = new List<ICmsPage>();
                CmsManager manager = new CmsManager();

                foreach (ICmsPage page in manager.GetPages())
                    if (page.Name.ToLower() == pageName.ToLower())
                        foreach (ICmsPage child in page.Pages)

                var result = from item in list
                             orderby item.DateModified descending
                             select item;

                return (IList<ICmsPage>)result;

    but I get the following area when trying to do the last cast to return the

    Unable to cast object of type 'System.Linq.OrderedEnumerable`2[Telerik.Cms.ICmsPage,System.DateTime]' to type 'System.Collections.Generic.IList`1[Telerik.Cms.ICmsPage]'.

    Any ideas???

  2. Filip
    Filip avatar
    9 posts
    04 Feb 2008
    28 Mar 2008
    Link to this post
    Well its clear from error message. You cant cast LINQ OrderedEnumerable to generic List. Look for method whitch will return IEnumerable interface.
  3. Yasen
    Yasen avatar
    121 posts
    18 May 2013
    01 Apr 2008
    Link to this post
    Hello sam,

    In order to get this code running, you could use 
        return result.ToList<ICmsPage>();

    instead of 
        return (IList<ICmsPage>)result;

    However, I am not sure what you need to achieve. Could you please eleborate a little more on your question about pages by guid?

    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Register for webinar
3 posts, 0 answered