如果使用分页,如何获取 radlistview 项目
Posted
技术标签:
【中文标题】如果使用分页,如何获取 radlistview 项目【英文标题】:How to get radlistview items if you use paging 【发布时间】:2013-10-08 13:36:58 【问题描述】:我在我的 asp.net 项目中使用 radlistview。当我必须获取 radlistview 的所有项目时,它只返回当前页面的项目。
例子:
radlistview2.Items.ToList();
输出: 我只有第一页中的 10 个元素
我的问题是:
如何获取 radlistview 中的所有项目 ???
【问题讨论】:
【参考方案1】:请尝试以下代码 sn-p。
ASPX
<telerik:RadListView ID="RadListView1" runat="server" OnNeedDataSource="RadListView1_NeedDataSource" AllowPaging="true" PageSize="2">
<ItemTemplate>
<%# Eval("ID") %>
</ItemTemplate>
</telerik:RadListView>
<telerik:RadDataPager ID="RadDataPager1" runat="server" PagedControlID="RadListView1"
PageSize="2">
<Fields>
<telerik:RadDataPagerButtonField FieldType="FirstPrev"></telerik:RadDataPagerButtonField>
<telerik:RadDataPagerButtonField FieldType="Numeric"></telerik:RadDataPagerButtonField>
<telerik:RadDataPagerButtonField FieldType="NextLast"></telerik:RadDataPagerButtonField>
</Fields>
</telerik:RadDataPager>
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
ASPX.CS
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;
RadListView1.Rebind();
int j = RadListView1.Items.Count();
//Access your count here
RadListView1.AllowPaging = true;
RadListView1.Rebind();
【讨论】:
以上是关于如果使用分页,如何获取 radlistview 项目的主要内容,如果未能解决你的问题,请参考以下文章
NativeScript:如果用户点击 RadListView 中的空白空间,我如何捕捉点击事件?
Nativescript:获取 RadListView 项目的视图
NativeScript Angular RadListView 渲染极其缓慢