Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > ListView > ListView, Paging and SortOrder

Not answered ListView, Paging and SortOrder

Feed from this thread
  • Posted on Feb 8, 2011 (permalink)

    Hello there!

    I'm facing a very strange behaviour.

    I'm using RadListView to display products on our Sitefinity-Website. The RadListView its bound to his data with NeedDataSource. The DataSource itself returns the products in right oder (sorted by name). While displaying the products in RadListView all in one time, it's working fine, but when I set AllowPaging=true, the items are not sorted any more by name. I don't know which field they are sorted by. I don't use any buttons oder code-behind to set a different sort expression and I'm sure that this behaviour is new, since one of the last updates of Sitefinity.

    Version 3.7 SP4 for .NET 4

    Has anyone an idea or has been facing a similar problem?

    Thanks in advance!

    Dieter

    Reply

  • Iana Tsolova Iana Tsolova admin's avatar

    Posted on Feb 11, 2011 (permalink)

    Hello Dieter,

    Can you try reproducing the problem in a simple web page outside Sitefinity?
    However, I need to mention that RadListView displayed the records as they are present in its data source. It does not perform any additional actions on its data source internally.

    Let me know how it goes.

    Greetings,
    Iana
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

    Reply

  • JM avatar

    Posted on Mar 3, 2011 (permalink)

    I'm experiencing the same thing.

    Reply

  • Posted on Mar 4, 2011 (permalink)

    Hi I am experiencing the same thing.

    I have a RadListView with a RadDataPager and when I set AllowPaging to false and sort the data bound to RadListView manually it works as expected. But when I set AllowPaging to true although the data that I bind to RadLisView is in correct order in ItemDataBound I get the DataItems as if the data is not sorted at all.

    protected void news_NeedDataSource(object sender, Telerik.Web.UI.RadListViewNeedDataSourceEventArgs e)
    {
        NewsManager manager = new NewsManager();
        foreach (SortFieldView view in SortByList)
        {
            if (view.SortDirection != SortDirection.None)
            {
                manager.AddSortField(view.SortField, view.SortDirection);
            }
        }
        var newsList = manager.GetNews();  
       
        List<NewsItem> list = newsList.ToList();
        news.DataSource = list;
    }
     
    protected void news_ItemDataBound(object sender, Telerik.Web.UI.RadListViewItemEventArgs e)
    {
        if (e.Item.ItemType == Telerik.Web.UI.RadListViewItemType.DataItem ||
           e.Item.ItemType == Telerik.Web.UI.RadListViewItemType.AlternatingItem)
        {
            RadListViewDataItem viewItem = (RadListViewDataItem)e.Item;
            NewsItemControl newsItemControl = (NewsItemControl)e.Item.FindControl("newsItem");
            NewsItem news = (NewsItem)viewItem.DataItem;
     
            newsItemControl.Update(news);
        }
    }

    <telerik:RadListView ID="news" runat="server"
        onitemdatabound="news_ItemDataBound"
        onneeddatasource="news_NeedDataSource" AllowPaging="true">
        <ItemTemplate>
            <uc2:NewsItemControl ID="newsItem" runat="server" />
        </ItemTemplate>
    </telerik:RadListView>
        <telerik:RadDataPager ID="pager" runat="server"
            PagedControlID="news" PageSize="4" EnableEmbeddedSkins="false">
            <Fields>           
                <telerik:RadDataPagerTemplatePageField HorizontalPosition="RightFloat" >
                    <PagerTemplate>
                        <asp:LinkButton Visible="<%# Container.Owner.StartRowIndex == 0 ? false : true %>"
                            ID="btnPrev" runat="server" CommandName="Page" CommandArgument="Prev">< Newer</asp:LinkButton>
                        <asp:LinkButton Visible="<%# Container.Owner.TotalRowCount < Container.Owner.StartRowIndex+Container.Owner.PageSize ? false : true %>"                        
                            ID="btnNext" runat="server" CommandName="Page" CommandArgument="Next">Older ></asp:LinkButton>                   
                    </PagerTemplate>
                </telerik:RadDataPagerTemplatePageField>
                <telerik:RadDataPagerTemplatePageField HorizontalPosition="RightFloat"  >
                    <PagerTemplate>                  
                        <asp:Label runat="server" ID="CurrentPageLabel" Text="<%# Container.Owner.StartRowIndex+1%>" />
                        to
                        <asp:Label runat="server" ID="TotalPagesLabel" Text="<%# Container.Owner.TotalRowCount < Container.Owner.StartRowIndex+Container.Owner.PageSize ?
                        Container.Owner.TotalRowCount : Container.Owner.StartRowIndex+Container.Owner.PageSize %>" />
                        of
                        <asp:Label runat="server" ID="TotalItemsLabel" Text="<%# Container.Owner.TotalRowCount%>" />
                        <br />
                    </PagerTemplate>
                </telerik:RadDataPagerTemplatePageField>
            </Fields>
        </telerik:RadDataPager>

    Thank you...

    Reply

  • Iana Tsolova Iana Tsolova admin's avatar

    Posted on Mar 7, 2011 (permalink)

    Hello,

    Is the issue you are facing available in a simple web site? Can you share it or some code where we can observe the problem?

    Kind regards,
    Iana
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!

    Reply

  • Posted on Mar 7, 2011 (permalink)

    Hi Iana,

    The problem occurs if I use ADO.NET Entity Model as a data source, if I use regular classes and Lists it doesn't happen.

    I attached a sample solution to my support ticket named "Sorting Problem with AllowPaging enabled".

    Thank you...

    Reply

  • Iana Tsolova Iana Tsolova admin's avatar

    Posted on Mar 7, 2011 (permalink)

    Hi Eric,

    I will check the sample you provided and turn back to you with my findings.
    In the meanwhile, can you try the same scenario with ASP:ListView so we can further isolate the issue?

    Best wishes,
    Iana
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!

    Reply

  • Posted on Mar 7, 2011 (permalink)

    It works with ASP:ListView.

    Note: In order to make ASP:ListView paging work with RadDataPager I had to convert the data source to a list by using ToList() method of IQueryable<T>. I also did the same in the RadListView need data source but it didn't work for RadListView.

    Thank you...

    Reply

  • Iana Tsolova Iana Tsolova admin's avatar

    Posted on Mar 8, 2011 (permalink)

    Hi Eric,

    I tested the project provided in the support thread and here are my findings:

    After further debugging it appeared the issue is due to a limitation in the Entity Framework. In order allow paging, e.g. to be able to call the Skip() and Take() methods, the list of records should be sorted. Therefore the RadListView is sorting the data source is sorted by the first data field. However I have forwarded the issue to our developers and they will change the listview behavior so sorting will work with page if the sorting is performed through the listview API, i.e. is sort expressions are added to it. In this case the sorting will be still performed at database level but the listview will pass the sort expressions to it for you.

    Regards,
    Iana
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!

    Reply

  • James avatar

    Posted on Mar 10, 2011 (permalink)

    Thought I'd mention I just found out about this issue today as well.

    This is a normal asp.net site where we upgraded the telerik components recently. I've done built in paging with a radlistview with older versions of telerik that work just fine. So guessing this is a recent issue.

    Reply

  • Iana Tsolova Iana Tsolova admin's avatar

    Posted on Mar 14, 2011 (permalink)

    Hi James,

    Thank you for sharing your finding with us and with the community. We will take them into account in performing further investigation and addressing the issue.

    Greetings,
    Iana
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!

    Reply

  • Tom avatar

    Posted on Jun 27, 2012 (permalink)

    Hello,

    I have just encountered this problem too. Do you know if it is now fixed? or is there a workaround i can use?

    Reply

  • Iana Tsolova Iana Tsolova admin's avatar

    Posted on Jun 28, 2012 (permalink)

    Hello,

    The issue is already fixed. If you are using the latest version you should not experience the behavior discussed in this thread.

    Regards,
    Iana Tsolova
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > ListView > ListView, Paging and SortOrder
Related resources for "ListView, Paging and SortOrder"

ASP.NET ListView Features  |  Documentation  |  DemosStep-by-step Tutorial  ]