对分层数据进行分页时页面大小的例外
我有一个网页,显示非常大的数据列表。 由于这会导致浏览器陷入困境,因此我实现了分页(使用 PagedDataSource)来一次显示 20 个弹珠。
我的数据模型是这样的,一个包包含多个弹珠,在我的中继器上,我显示一个包信息的小标题,然后显示其下面的所有弹珠。
过于简单的例子:
Bag1 some Bag specific data -------------------------------------- MarbleA 328 Some St. USA MarbleB 364 another ave. USA MarbleC 7878 Whatever Way USA Bag2 some Bag specific data -------------------------------------- MarbleD 684 Dummy Dr. USA etc.
问题是,由于我的页面大小是 20,我可以在页面末尾切掉袋子的弹珠。 (假设 MarbleB 是第 20 个元素。)这会导致剩余的 Marbles 溢出到下一页的顶部。
有没有任何优雅的方法来检查这一点,或者我是否必须实现自己的分页并添加“向前查看直到下一个包”逻辑?
编辑: 假设c# 2.0、VS2008、SQL 2005
I have a webpage that displays a very large list of data. Since this was bogging down the browser, I implemented paging (using a PagedDataSource) to display 20 Marbles at a time.
My data model is such that a Bag contains multiple Marbles, and on my repeater I show a little header for the Bag information then all of the Marbles underneath it.
Oversimplified example:
Bag1 some Bag specific data -------------------------------------- MarbleA 328 Some St. USA MarbleB 364 another ave. USA MarbleC 7878 Whatever Way USA Bag2 some Bag specific data -------------------------------------- MarbleD 684 Dummy Dr. USA etc.
The problem is, since my page size is 20, I can cut off a Bag's Marbles on the end of a page. (Imagine MarbleB was the 20th element.) This causes the remaining Marbles to spill over to the top of the next page.
Is there any elegant way to check for this, or am I going to have to implement my own paging and add a "look ahead until the next bag" logic?
Edit:
assume c# 2.0, VS2008, SQL 2005
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 SQL 查询来处理其中一些(假设 SQL Server 2005)。 如果引入 RANK 作为结果,您可以确定每个结果占用多少行。 下面是一个可能位于存储过程中的示例查询:
@BagID 将是“起始”BagID(最初为 -1),如果需要,您可以使用之前结束的 BagID 来调用它。
结果看起来像这样:
在分页中,您可以检查 RowNum 列,看看它是否在页面大小的限制内。 当然,缺点是如果您的袋子里有大量弹珠等。
编辑:如果您的 RDBMS 中无法使用 RANK 功能,则可能会出现类似的结果使用临时表和游标在存储过程中完成。
You could handle some of it with your SQL query (assuming SQL Server 2005). If you introduce RANK as a result you could make a determination of how many rows each result takes up. Here's a sample query that could be within a sproc:
@BagID would be the "starting" BagID (initially -1), you could call it with the previously ending BagID if you wanted.
The results would look something like this:
Within your pagination you could do a check on the RowNum column to see if it's within the limit of the page size. Of course, the draw back would be if you had a bag with a large amount of marbles within it, etc.
EDIT: If RANK functionality is not available to you within your RDBMS, a similar result could be accomplished within a sproc using a temp table and a cursor.