ASP.NET 自定义分页

发布于 2024-09-11 16:29:27 字数 214 浏览 0 评论 0原文

如何为动态结果集保留自定义分页? (即)基于 10 个下拉菜单选择,我的存储过程将动态生成结果集,但它会填充数百万条记录。

Row静态地知道记录数,自定义分页是高效的,但是对于动态增长的结果集如何实现呢?

问题

我必须将通用列表绑定到 GridView,列是固定的,但重新调整的行数未知,但如果没有自定义分页,我的 GridView 需要 30 分钟才能填充结果。

How to keep custom paging for dynamic result sets ? (i.e) based on 10 Dropdowns selection my stored procedure will Dynamically generates resultset,but it populates million records.

Row statically know Record count,cusom paging is efficient,but how to achieve it for dynamically grown result set?

Problem

I have to bind generic List to GridView,Columns are fixed,but the number of rows retuened are unknown,but without custom paging my GridView took 30 minutes to populate the result.

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

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

发布评论

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

评论(2

凹づ凸ル 2024-09-18 16:29:27

如果可能,您应该使用 LINQ,因为可扩展操作可以轻松进行分页。

本质上,您可以指定 ObjectDataSourceLinqDataSource 用于您的 GridView。

然后,您将拥有一个 IQueryable 方法,该方法接受起始位置和要检索的行数。

然后利用Skip()Take()来实现简单的分页。

这是一篇关于执行此操作的非常好的文章。

请记住,Skip()Take() 是向任何实现 IEnumerable 的类公开的方法。因此,即使上面的文章使用 LINQ-SQL 作为数据存储库,只要您自己的 DAL 公开了 IEnumerable 类型的集合,您就可以使用 Skip and Take 模式。

希望有帮助。

If possible, you should use LINQ, as the extensible operations make for easy paging.

Essentially, you would specify an ObjectDataSource or LinqDataSource for your GridView.

You would then have an IQueryable<T> method which accepts a starting position and number of rows to retrieve.

Then you make use of Skip() and Take() to achieve simple paging.

Here's a very good article on doing that.

Remember that Skip() and Take() are methods exposed to any class which implements IEnumerable. So even though the above article uses LINQ-SQL for their data repository, as long as your own DAL exposes a collection of type IEnumerable, you can use the Skip and Take pattern.

Hope that helps.

挽清梦 2024-09-18 16:29:27

在服务器端执行此操作的一个简单方法是使用 LINQ。采用 .Take() 方法。

An easy way to do this server side would be to use LINQ. Took at the .Take() method.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文