This is a migrated thread and some comments may be shown as answers.
RadDataPager Question
1 Answer 49 Views
This is a migrated thread and some comments may be shown as answers.
robertw102
Top achievements
Rank 1
robertw102 asked on 23 Mar 2010, 08:39 PM
My situation is that I have a RadListView with RadDataPager, to display a bunch of calendars. I set the datasource of the RadListView in the code-behind and everything loads correctly. The problem is that the paging functionality does not work. I've created test page that replicates my issue.

My ASPX page:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
<head runat="server"
    <title></title
</head> 
<body> 
    <form id="form1" runat="server"
    <div> 
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server"
        </telerik:RadScriptManager> 
        <telerik:RadListView ID="lvItems" runat="server" AllowPaging="true"
            <LayoutTemplate> 
                <telerik:RadDataPager ID="dpTopPager" runat="server" PagedControlID="lvItems" PageSize="7" 
                    Skin="Office2007"
                    <Fields> 
                        <telerik:RadDataPagerButtonField FieldType="Numeric" PageButtonCount="10" /> 
                    </Fields> 
                </telerik:RadDataPager> 
                <asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder> 
            </LayoutTemplate> 
            <ItemTemplate> 
                <div> 
                    <%#DataBinder.Eval(Container, "DataItem.Value") %> 
                </div> 
            </ItemTemplate> 
        </telerik:RadListView> 
    </div> 
    </form> 
</body> 
</html> 
 

The code-behind:
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
 
public partial class Test : System.Web.UI.Page 
    protected void Page_Load(object sender, EventArgs e) 
    { 
        if (!Page.IsPostBack) 
        { 
            Dictionary<intint> items = new Dictionary<intint>(); 
 
            for (int i = 0; i < 23; i++) 
            { 
                items.Add(i, i); 
            } 
 
            lvItems.DataSource = items.ToList(); 
            lvItems.DataBind(); 
        } 
    } 
 

It's a simple demo, it just renders numbers. Now I notice that because I only bind my results on the first load that the paging doesn't work. I noticed that the normal asp.net DataPager control acts the same way, so is it just not possible to enable paging if I don't rebind the RadListView every time the page is changed or am I doing something wrong.?

Thanks.

1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 25 Mar 2010, 07:46 AM
Hi Robert,

In your scenario you should consider using Advanced DataBinding through NeedDataSource event. As you may know NeedDataSource event will be raised only when the data is needed i.e. on paging, sorting, filtering etc. 

All the best,
Rosen
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Asked by
robertw102
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or