I changed something from demo example to my project and i use datasource in codebehind. DataPager still works fine if i put RadListView datasource in PageLoad but DataPager doesn't work when i put RadListView datasource in event click of Button. Can you help me, please?
- aspx:
<telerik:RadButton ID="RadButton1" runat="server" Text="RadButton" OnClick="Button1_Click"></telerik:RadButton>
<br />
<div>
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="ListViewPanel1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="ListViewPanel1" LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl>
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" MinDisplayTime="0">
</telerik:RadAjaxLoadingPanel>
<asp:Panel ID="ListViewPanel1" runat="server">
<telerik:RadListView ID="RadListView1" Width="97%" AllowPaging="True" runat="server"
allowsorting="true" ItemPlaceholderID="ProductsHolder">
<LayoutTemplate>
<asp:Panel ID="ProductsHolder" runat="server">
</asp:Panel>
<table>
<tr>
<td>
<telerik:RadDataPager RenderMode="Lightweight" ID="RadDataPager1" runat="server" PagedControlID="RadListView1"
PageSize="6">
<Fields>
<telerik:RadDataPagerButtonField FieldType="FirstPrev"></telerik:RadDataPagerButtonField>
<telerik:RadDataPagerButtonField FieldType="Numeric"></telerik:RadDataPagerButtonField>
<telerik:RadDataPagerButtonField FieldType="NextLast"></telerik:RadDataPagerButtonField>
<telerik:RadDataPagerPageSizeField PageSizeText="Page size: "></telerik:RadDataPagerPageSizeField>
<telerik:RadDataPagerGoToPageField CurrentPageText="Page: " TotalPageText="of" SubmitButtonText="Go"
TextBoxWidth="30"></telerik:RadDataPagerGoToPageField>
<telerik:RadDataPagerTemplatePageField>
<PagerTemplate>
<div style="float: right; line-height: 34px; margin-left: 10px;">
Items
<asp:Label runat="server" ID="CurrentPageLabel" Text="<%# Container.Owner.StartRowIndex+1%>"></asp:Label>
to
<asp:Label runat="server" ID="TotalPagesLabel" Text="<%# Container.Owner.TotalRowCount > (Container.Owner.StartRowIndex+Container.Owner.PageSize) ? Container.Owner.StartRowIndex+Container.Owner.PageSize : Container.Owner.TotalRowCount %>"></asp:Label>
of
<asp:Label runat="server" ID="TotalItemsLabel" Text="<%# Container.Owner.TotalRowCount%>"></asp:Label>
<br />
</div>
</PagerTemplate>
</telerik:RadDataPagerTemplatePageField>
</Fields>
</telerik:RadDataPager>
</td>
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<table>
<tr>
<td style="width: 140px; text-align: left; height: 120px">
<asp:Image ID="Img1" runat="server"
ImageUrl='<%# Eval("_Image") %>' Height="100" Width="130" />
</td>
<td style="vertical-align: top; text-align: left">
<asp:LinkButton runat="server" ID="Title" Font-Bold="true" CommandName="Select"
Text='<%# Eval("_Title") %>'></asp:LinkButton>
<asp:Label runat="server" ID="lblink" Font-Size="Small"
Text='<%# Eval("_Link") %>' Visible="false" />
</td>
</tr>
</table>
</ItemTemplate>
</telerik:RadListView>
</asp:Panel>
<asp:SqlDataSource ID="SqlDS" runat="server" ConnectionString="<%$ appSettings:sqlconn %>"
ProviderName="System.Data.SqlClient" ></asp:SqlDataSource>
- aspx.cs work fine (don't use Button):
protected void Page_Load(object sender, EventArgs e)
{
_News.NewsList("20", "", "08/20/2016", "08/30/2016", "0", "0", 0);
RadListView1.DataSource = _News._znews;
RadListView1.DataBind();
}
- aspx.cs DataPager doesn't work:
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
_News.NewsList("20", "", "08/20/2016", "08/30/2016", "0", "0", 0);
RadListView1.DataSource = _News._znews;
RadListView1.DataBind();
}
Thanks.