简体   繁体   English

如何基于行数据在ac#.NET gridview中设置分页?

[英]How do I set up paging in a c# .NET gridview based on row data?

My data look like this: 我的数据如下所示:

col1
------
val1
val1
val1
val2
val2
val3

I would like my GridView to page the data based on the value in col1. 我希望我的GridView基于col1中的值来分页数据。 So page 1 should show the 3 rows with val1 . 因此,第1页应显示val1的3行。 Page 2 would show 2 rows with val2 . 第2页将显示val2 2行。 Page 3 would show 1 row with val3 页面3将显示1行与val3

What is the best way to achieve this? 实现此目标的最佳方法是什么?

Have you tried to use the "ORDER BY" in your mysql connection? 您是否尝试过在MySQL连接中使用“ ORDER BY”? It should look something like.. 它应该看起来像..

SELECT * FROM yourTable
  ORDER BY col1 ASC;

Hope this helps! 希望这可以帮助!

Enable the paging for Gridview and set the GridView page size to the actual limit u want. 为Gridview启用分页,并将GridView页面大小设置为所需的实际限制。

Links that might help you: 可能会帮助您的链接:

1) http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.allowpaging.aspx 1) http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.allowpaging.aspx

2) http://msdn.microsoft.com/en-us/library/y71xk4a7.aspx 2) http://msdn.microsoft.com/en-us/library/y71xk4a7.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM