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<int, int> items = new Dictionary<int, int>(); |
| 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.