RadListView doesnt display paged datasource results

3 posts, 0 answers
  1. Matthew
    Matthew avatar
    7 posts
    Member since:
    Oct 2012

    Posted 12 Nov 2014 Link to this post

    I have a RadListView that is paged by a RadDataPager. The ListView is loaded correctly on the initial page load. After that the needdatasource method correctly retrieves the next set of results, but they are never displayed. From my investigation, it appears that it is related to the fact that the listview always has a page count of 1 while the datapager correctly calculates 2(13 items, with a page size of 10). The list view changes page index correctly, which retrieves the next page of results to set for the datasource. After setting the datasource the new items are never displayed. I am doing something very similar to the listview image gallery demo, so if it at least tried to add the new images and failed, I should get broken image links.  I think the listview is skipping binding the new results, since the list view thinks its out of its page range. Its worth noting we are using the 2013 Q2 controls, since this is new work for a customer with an existing site. We want to avoid updating versions to limit risk to the rest of the site.

    <telerik:RadListView runat="server" ID="ImageGalleryDisplay" OnNeedDataSource="ImageGalleryDisplay_NeedDataSource" OnItemCreated="RadListView1_ItemCreated"
                    AllowPaging="true" ItemPlaceholderID="ImagePlaceHolder" OnItemDataBound="RadListView_ItemDataBound">
                           <asp:PlaceHolder ID="ImagePlaceHolder" runat="server">
                           <telerik:RadDataPager ID="RadDataPager1" runat="server" PagedControlID="ImageGalleryDisplay"
                                <telerik:RadDataPagerButtonField FieldType="FirstPrev"></telerik:RadDataPagerButtonField>
                                <telerik:RadDataPagerButtonField FieldType="Numeric"></telerik:RadDataPagerButtonField>
                                <telerik:RadDataPagerButtonField FieldType="NextLast"></telerik:RadDataPagerButtonField>
                            <asp:Image ID="Image1" runat="server" ImageUrl='<%#Eval("ImageURL")%>' />
                            <asp:Image ID="Image2" runat="server" ImageUrl='<%#Eval("ImageURL")%>' />

    protected void ImageGalleryDisplay_NeedDataSource (object source, RadListViewNeedDataSourceEventArgs e)
                _photos = new List<Photo> ();
                LoadData ();
                ImageGalleryDisplay.DataSource = _photos;

            protected void LoadData ()
                //dataSearch is our own special search type that returns a datatable and estimated hit count, they return the correct values

                DataTable fileIds = dataSearch.Retrieve<DataTable> (ImageGalleryDisplay.CurrentPageIndex * ImageGalleryDisplay.PageSize + 1, ImageGalleryDisplay.PageSize);
                ImageGalleryDisplay.VirtualItemCount = dataSearch.EstimateHitCount > 0 ? dataSearch.EstimateHitCount : 0;

                foreach (DataRow row in fileIds.Rows)
                    int id = Convert.ToInt32 (row["fileId"].ToString ());

                    Photo photo = new Photo (id, String.Format("Handlers/ImageHandler.ashx?id={0}&height=100&width=100",id));
                    _photos.Add (photo);

            protected void RadListView_ItemDataBound (object sender, RadListViewItemEventArgs e)
                if (e.Item is RadListViewDataItem)
                    var dataItem = ((RadListViewDataItem)e.Item).DataItem;


            protected void RadListView1_ItemCreated (object sender, RadListViewItemEventArgs e)
                if (e.Item is RadListViewDataItem)
                    Image img = e.Item.FindControl ("image1") as Image;

            protected void Comand2 (object sender, RadListViewPageChangedEventArgs e)
                ImageGalleryDisplay.CurrentPageIndex = e.NewPageIndex;
                string i = ImageGalleryDisplay.PageCount.ToString();

  2. Matthew
    Matthew avatar
    7 posts
    Member since:
    Oct 2012

    Posted 12 Nov 2014 in reply to Matthew Link to this post

    I was able to resolve the issue by adding AllowCustomPaging=true. What am i doing differently that is requiring custom paging to be turned on? All examples that I see, do not set that when using a raddatapager.
  3. DevCraft R3 2016 release webinar banner
  4. Konstantin Dikov
    Konstantin Dikov avatar
    1754 posts

    Posted 17 Nov 2014 Link to this post

    Hello Matthew,

    Since you are setting multiple properties related to the paging, in order go get the paging to work as you are expecting, as you have found out yourself, you need to set the AllowCustomPaging to true.

    In the following help article you can find detailed information on this matter:

    Best Regards,
    Konstantin Dikov

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top