Sorting not working

6 posts, 0 answers
  1. Iker Llanos
    Iker Llanos avatar
    12 posts
    Member since:
    Apr 2010

    Posted 07 Jan 2011 Link to this post

    I'm trying to sort a ListView but no way. I will explain what I've done:

    - I get a List of products that containt an Order field (Orden integer)
    - I put this datasource to the listview and databind()
    - In the ascx I have this code:
    <asp:Panel ID="listViewPanelProductos" CssClass="ListViewList" runat="server">
        <telerik:RadListView ID="lvProductos" runat="server" AllowPaging="true" 
             EnableViewState="true" OnItemDataBound="lvProductos_ItemDataBound"
        ItemPlaceholderID="ProductosContainer" DataKeyNames="IdProducto">        
    <SortExpressions>
                <telerik:RadListViewSortExpression FieldName="Orden" SortOrder="Ascending" />
            </SortExpressions>
            <LayoutTemplate>                        
                <fieldset id="fieldSet" class="fieldSet">                
                    <asp:PlaceHolder ID="ProductosContainer" runat="server" />
                    <div style="clear:both"></div>
                    <table cellpadding="0" cellspacing="0" style="margin:auto; padding-top:15px;">
                        <tr>
                            <td>
                                <telerik:RadDataPager ID="pager" runat="server" PagedControlID="lvProductos" PageSize="10" Skin="Default" AllowSEOPaging="true" SEOPagingQueryPageKey="pag">
                                    <Fields>
                                        <telerik:RadDataPagerButtonField FieldType="Prev" />
                                        <telerik:RadDataPagerButtonField FieldType="Numeric" />
                                        <telerik:RadDataPagerButtonField FieldType="Next" />
                                    </Fields>
                                </telerik:RadDataPager>
                            </td>
                        </tr>
                    </table>
                </fieldset>
            </LayoutTemplate>
            <ItemTemplate>        
                <div class="item">
                    <div class="tituloProducto">
                        <h2>                        
                            <asp:HyperLink ID="lnkTitulo" Text='<%# Eval("Titulo") %>' ToolTip='<%# Eval("Titulo") %>'
                                runat="server" EnableViewState="false" />
                        </h2>
                    </div>
                    <div class="descripcionProducto">
                        <asp:Label ID="lblDescripcion" runat="server" EnableViewState="false"></asp:Label>
                    </div>
                </div>
            </ItemTemplate>
    .
    .
    .
    .
    .

    - No sorting happens.

    What am I doing wrong?

    Thanks
  2. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 07 Jan 2011 Link to this post

    Hello Iker,

    The correct approach when using simple data-binding is to call the DataBind() method on the first page load when !Page.IsPostBack and after handling some event (sort event for example). Keep in mind that if you choose simple data-binding, you will need to assign data-source and rebind the grid after each operation (paging, sorting, editing, etc.) - this copies exactly MS ListView behavior.

    You can also review the corresponding online demo of the product which illustrates direct comparison between the simple and advanced binding of RadListView.

    I hope this helps.

    All the best,
    Pavlina
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Iker Llanos
    Iker Llanos avatar
    12 posts
    Member since:
    Apr 2010

    Posted 10 Jan 2011 Link to this post

    I'm trying this with an entity datasource and it doesn't work either:

    <asp:Panel ID="listViewPanelProductos" CssClass="ListViewList" runat="server">
        <telerik:RadListView ID="lvProductos" runat="server" AllowPaging="true"
             EnableViewState="true" OnItemDataBound="lvProductos_ItemDataBound"
        ItemPlaceholderID="ProductosContainer" DataKeyNames="IdProducto" DataSourceID="dsProductos">       
            <LayoutTemplate>                       
                <fieldset id="fieldSet" class="fieldSet">               
                    <asp:PlaceHolder ID="ProductosContainer" runat="server" />
                    <div style="clear:both"></div>
                    <table cellpadding="0" cellspacing="0" style="margin:auto; padding-top:15px;">
                        <tr>
                            <td>
                                <telerik:RadDataPager ID="pager" runat="server" PagedControlID="lvProductos" PageSize="10" Skin="Default" AllowSEOPaging="true" SEOPagingQueryPageKey="pag">
                                    <Fields>
                                        <telerik:RadDataPagerButtonField FieldType="Prev" />
                                        <telerik:RadDataPagerButtonField FieldType="Numeric" />
                                        <telerik:RadDataPagerButtonField FieldType="Next" />
                                    </Fields>
                                </telerik:RadDataPager>
                            </td>
                        </tr>
                    </table>
                </fieldset>
            </LayoutTemplate>
            <ItemTemplate>       
                <div class="item">
                    <div class="tituloProducto">
                        <h2>                       
                            <asp:HyperLink ID="lnkTitulo" Text='<%# Eval("Titulo") %>' ToolTip='<%# Eval("Titulo") %>'
                                runat="server" EnableViewState="false" />
                        </h2>
                    </div>
                    <div class="descripcionProducto">
                        <asp:Label ID="lblDescripcion" runat="server" EnableViewState="false"></asp:Label>
                    </div>
                </div>
            </ItemTemplate>
     
    <asp:EntityDataSource ID="dsProductos" runat="server"
        ConnectionString="name=Entities"
        DefaultContainerName="Entities" EntitySetName="productos"
        OrderBy="it.Orden ASC">
    </asp:EntityDataSource>
  5. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 11 Jan 2011 Link to this post

    Hi Iker,

    To enable sorting functionality for the RadListView  you should add a SortExpression object to the SortExpressions collection as demonstrated in the following help article:
    http://www.telerik.com/help/aspnet-ajax/listview-sorting.html

    Additionally, note that when Sort/Page commands are triggered RadListView requires to re-bind in order to process the command.
    You can find list of commands the call rebind implicitly on the article bellow:
    http://www.telerik.com/help/aspnet-ajax/listview-commands-invoking-rebind-implicitly.html

    Greetings,
    Pavlina
    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.
  6. JM
    JM avatar
    7 posts
    Member since:
    Sep 2006

    Posted 03 Mar 2011 Link to this post

    It's probably a bug.. Try setting AllowPaging to  false.
  7. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 08 Mar 2011 Link to this post

    Hi,

    To fix the problem with sorting, you will need to upgrade to the latest version of RadControls for ASP.NET AJAX:
    http://www.telerik.com/support/kb/aspnet-ajax/general/updating-radcontrols-for-asp-net-to-another-version-or-license.aspx

    Best wishes,
    Pavlina
    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!
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017