gridview分页的PagedDatasource

发布于 2024-12-01 03:33:07 字数 627 浏览 2 评论 0 原文

我正在使用 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

I am using PagedDataSource for gridview's custom paging. Here is the code:

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();

I am returning the "totalrows" from my Stored procedure (which is set in virtualRowCount) and actual rows in tables[0] of dataset. I am getting the results however my pager is gone. The pager is no longer shown. How can I tell the gridview to pick up value from PagedDataSource?

Working with ASP.Net 4

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

忆依然 2024-12-08 03:33:07

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

ASP.NET 2.0+ Version

This post here http://www.codewrecks.com/blog/index.php/2008/02/09/aspnet-20-gridview-custom-sorting-with-pageddatasource/ extends the standard GridView and provides plumbing code to achieve PagedDataSource integration.

ASP.NET 4.5 Version

Set the AllowPaging and AllowCustomPaging attribute on the GridView as well as the Paged data source property?

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();

Additionally this post may also be of help http://www.byteblocks.com/post/2012/03/20/Use-Custom-Paging-in-Grid-View.aspx

太阳哥哥 2024-12-08 03:33:07
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();
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();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文