如何在ASP.NET分页工作(使用VB.NET)? [英] How does pagination work in ASP.NET(Using VB.NET)?

查看:83
本文介绍了如何在ASP.NET分页工作(使用VB.NET)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何创建和填充一个DataTable,我已经做了。现在,我只是想显示在一个WebForm的数据表,但我也想知道如何进行分页和排序。最后,我不想把它绑定到DataGrid或GridView控件。我想学习如何编程这样做我自己。

I know how to create and populate a datatable, which i have already done. Now, I simply want to display the datatable on a webform, but I also want to know how to paginate and sort it. Ultimately I do not want to bind this to a datagrid or gridview. I would like to learn how to programmatically do this myself.

你能告诉我如何显示,分页,并且不使用数据网格或GridView的排序数据表本?

Can you tell me how to display, paginate, and sort this datatable without using datagrid or gridview?

感谢您!

推荐答案

理想分页是在数据库级别上完成的。对于您创建的这可能需要两个参数,一个SP。一会是否定的。记录要显示在每一页上和另一个参数会没有。页面的用户已经打开。

Ideal pagination is done at database level. For that you create a SP which might take two parameters. One would be the no. of records you want to show on each page and another parameter would no. of page that your user is on.

例如 - 如果你的用户是第1页和每页记录是20,然后从数据库检索记录,其中行ID是从1到20,如果用户想要见第3页,然后检索行41至60。如果你不必在你的SQL表的唯一标识符,那么你将不得不使用内部的查询与ROW_NUMBER()函数的帮助。以下是使用SQL Server ROW_NUMBER()函数来寻呼链路

For example - if your user is on page 1 and records per page is 20, then retrieve records from your db where row id is from 1 to 20. if user wants to see page 3 then retrieve row 41 to 60. If you do not have uniqueidentifier in your SQL table then you would have to use inner query with the help of ROW_NUMBER() function. Following is a link to paging using SQL Server ROW_NUMBER() function.

http://www.davidhayden.com/博客/戴维/存档/ 2005/12/30 / 2652.aspx

沿着这个逻辑,你还可以结合分拣的一面。这可能是你的SP第三个参数。你可以先以任何方式对数据进行排序,然后采取正确的页面了。

Along side of this logic you can also combine sorting. That could be a third parameter to your SP. You can first sort your data in any way and then take a proper page out.

这篇关于如何在ASP.NET分页工作(使用VB.NET)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆