How to get radlistview items if you use paging

I’m using radlistview in my project . The problem that when I have to get all items of radlistview it return only items of the current page.

Example :


Output :
I got only 10 elements which are in the first page

My Question is :

How To get all items in radlistview ???

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

Please try with the below code snippet.


<telerik:RadListView ID="RadListView1" runat="server" OnNeedDataSource="RadListView1_NeedDataSource" AllowPaging="true" PageSize="2">
                <%# Eval("ID") %>
        <telerik:RadDataPager ID="RadDataPager1" runat="server" PagedControlID="RadListView1"
                <telerik:RadDataPagerButtonField FieldType="FirstPrev"></telerik:RadDataPagerButtonField>
                <telerik:RadDataPagerButtonField FieldType="Numeric"></telerik:RadDataPagerButtonField>
                <telerik:RadDataPagerButtonField FieldType="NextLast"></telerik:RadDataPagerButtonField>
        <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />


protected void RadListView1_NeedDataSource(object sender, RadListViewNeedDataSourceEventArgs e)
    dynamic data1 = new[] {
           new { ID = 1, Name ="Name_1",Customdate = DateTime.Now},
           new { ID = 2, Name = "Name_2",Customdate = DateTime.Now},
           new { ID = 3, Name = "Name_3",Customdate = DateTime.Now},
           new { ID = 4, Name = "Name_4",Customdate = DateTime.Now},
           new { ID = 5, Name = "Name_5",Customdate = DateTime.Now}
    RadListView1.DataSource = data1;
protected void Button1_Click(object sender, EventArgs e)
    int i = RadListView1.Items.Count();

    RadListView1.AllowPaging = false;

    int j = RadListView1.Items.Count();
    //Access your count here

    RadListView1.AllowPaging = true;


Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply