用于gridview分页的PagedDatasource

问题描述 投票:0回答:2

我正在使用 PagedDataSource 进行 gridview 的自定义分页。这是代码:

PagedDataSource dataSource = new PagedDataSource();

int virtualRowCount = Convert.ToInt32(dataset.Tables[1].Rows[0]["TotalRows"]);
dataSource.AllowCustomPaging = true;
dataSource.PageSize = 15;

dataSource.VirtualCount = virtualRowCount;
dataSource.DataSource = dataset.Tables[0].DefaultView;


gvTaxPayerLoginDetail.DataSource = dataSource;
gvTaxPayerLoginDetail.DataBind();

我从存储过程(在 virtualRowCount 中设置)返回“totalrows”,并返回数据集

tables[0]
中的实际行。我正在得到结果,但我的寻呼机不见了。寻呼机不再显示。我如何告诉 gridview 从 PagedDataSource 获取值?

使用 ASP.Net 4

asp.net gridview pagination custompaging
2个回答
3
投票

ASP.NET 2.0+版本

这里的这篇文章http://www.codewrecks.com/blog/index.php/2008/02/09/aspnet-20-gridview-custom-sorting-with-pageddatasource/扩展了标准GridView并提供了管道代码实现PagedDataSource集成。

ASP.NET 4.5版本

在GridView 上设置AllowPaging 和AllowCustomPaging 属性以及Paged 数据源属性?

PagedDataSource dataSource = new PagedDataSource();

int virtualRowCount = Convert.ToInt32(dataset.Tables[1].Rows[0]["TotalRows"]);
dataSource.AllowCustomPaging = true;
dataSource.PageSize = 15;

dataSource.VirtualCount = virtualRowCount;
dataSource.DataSource = dataset.Tables[0].DefaultView;

gvTaxPayerLoginDetail.AllowPaging = true; // See this line here
gvTaxPayerLoginDetail.AllowCustomPaging = true; // and this line here
gvTaxPayerLoginDetail.DataSource = dataSource;
gvTaxPayerLoginDetail.DataBind();

此外,这篇文章也可能有帮助http://www.byteblocks.com/post/2012/03/20/Use-Custom-Paging-in-Grid-View.aspx


1
投票
PagedDataSource dataSource = new PagedDataSource();

int virtualRowCount = Convert.ToInt32(dataset.Tables[1].Rows[0]["TotalRows"]);

dataSource.DataSource = dataset.Tables[0].DefaultView;

dataSource.AllowCustomPaging = true;
dataSource.PageSize = 15;
dataSource.VirtualCount = virtualRowCount;
dataSource.CurrentPageIndex  =0;

gvTaxPayerLoginDetail.DataSource = dataSource;
gvTaxPayerLoginDetail.AllowPaging=True;
gvTaxPayerLoginDetail.DataBind();
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.