C# windows 应用程序中的 Datagridview 分页
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2108444/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Datagridview pagination in C# windows application
提问by kiran
Hai guys,
各位海
- Can we implement default pagination like asp:gridview for a datagridview in a c# windows application?
- Any samples to get started?
- 我们可以在 ac# windows 应用程序中为 datagridview 实现像 asp:gridview 这样的默认分页吗?
- 有任何示例可以开始吗?
采纳答案by Restuta
回答by Raju yourPepe
Create Button as Last , First, Prev , Next
Implement the page function
创建按钮为 Last , First , Prev , Next
实现页面功能
Next( less than total increase current page position , And reload data source )
Next(小于总增加当前页面位置,并重新加载数据源)
Prev ( more than 1 decrease current page position and reload data source ) .. and so on
上一页(减少 1 个以上的当前页面位置并重新加载数据源).. 等等
- Write two SQLs for the following :
- get row counts of your search query
- get query result with no. of rows skipped and limit (no. of records per page)
- 为以下内容编写两个 SQL:
- 获取搜索查询的行数
- 获取没有的查询结果。跳过的行数和限制(每页记录数)
Remarks: try to find any functions for SQL such as limit , offset to skip the rows
备注:尝试查找任何 SQL 函数如 limit 、 offset 以跳过行
Most of the tutorials use SQL : select top N ..where not in ( select top b*N ) ... where N is the no. of records per page , b is the offset parameters ( current page - 1 ) to skip result rows.
大多数教程使用 SQL:select top N ..where not in ( select top b*N ) ... where N is the no。每页记录数,b 是跳过结果行的偏移参数(当前页 - 1)。
Beware the performance issues occured when querying the large result.
请注意查询大结果时出现的性能问题。