我的ASP.Net应用程序中有一个RadGrid,我将AllowPaging设置为True,PageSize设置为10,现在每个RadGridPage加载10个项目,这就是我想要的,但是只要按下Next Page按钮(箭头看按钮)没有任何负载,RadGrid变空.
我怎样才能让它正常工作?
我怎样才能让它正常工作?
protected void Page_Load(object sender,EventArgs e) { PopulateGridOnLoad(); } private void PopulateGridOnLoad() { rgCustomers.DataSource = odsCustomers; // your datasource type rgCustomers.MasterTableView.VirtualItemCount = 28; //your datasource type total/count rgCustomers.CurrentPageIndex = rgCustomers.MasterTableView.CurrentPageIndex; rgCustomers.Rebind(); } protected void GrdName_NeedDataSource(object sender,Telerik.Web.UI.GridNeedDataSourceEventArgs e) { rgCustomers.DataSource = odsCustomers; // your datasource type rgCustomers.MasterTableView.VirtualItemCount = 28; //your datasource type total/count rgCustomers.CurrentPageIndex = rgCustomers.MasterTableView.CurrentPageIndex; //Donot rebind here } protected void btnLoad_Click(object sender,EventArgs e) { odsCustomers.SelectParameters["CustomerFullName"].DefaultValue = txtFullName.Text; odsCustomers.SelectParameters["CustomerMellicode"].DefaultValue = txtMellicode.Text; odsCustomers.SelectParameters["CustomerHomeAddress"].DefaultValue = txtHomeAddresspart.Text; odsCustomers.SelectParameters["CustomerWorkAddress"].DefaultValue = txtWorkAddresspart.Text; rgCustomers.DataSource = odsCustomers; rgCustomers.DataBind(); }
解决方法
您必须在设计中设置网格的以下属性
<telerik:RadGrid ID="GrdName" AllowPaging="True" AllowCustomPaging="True" VirtualItemCount="0" PageSize="15" >
在加载vb.net上填充网格
Private Sub PopulateGridOnLoad() GrdName.DataSource = source ' your datasource type GrdName.MasterTableView.VirtualItemCount = source.Total 'your datasource type total/count GrdName.CurrentPageIndex = GrdName.MasterTableView.CurrentPageIndex GrdName.Rebind() End Sub
在加载c#.net上填充网格
private void PopulateGridOnLoad() { GrdName.DataSource = source; // your datasource type GrdName.MasterTableView.VirtualItemCount = source.Total; //your datasource type total/count GrdName.CurrentPageIndex = GrdName.MasterTableView.CurrentPageIndex; GrdName.Rebind(); }
覆盖NeedDatasource vb.net
Protected Sub GrdName_NeedDataSource(sender As Object,e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles GrdName.NeedDataSource GrdName.DataSource = source ' your datasource type GrdName.MasterTableView.VirtualItemCount = source.Total 'your datasource type total/count GrdName.CurrentPageIndex = GrdName.MasterTableView.CurrentPageIndex 'Donot rebind here End Sub
覆盖NeedDatasource c#
protected void GrdName_NeedDataSource(object sender,Telerik.Web.UI.GridNeedDataSourceEventArgs e) { GrdName.DataSource = source; // your datasource type GrdName.MasterTableView.VirtualItemCount = source.Total; //your datasource type total/count GrdName.CurrentPageIndex = GrdName.MasterTableView.CurrentPageIndex; //Donot rebind here }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。