获取用户名以“A”开头的前 10 位用户 (ASP.NET)
我想创建自己的分页控件,并且想用它来列出网格中的用户。
不知何故,我只需要获取首页的前 10 个用户,然后是 10-20 个用户,依此类推。
我在成员资格命名空间中找不到任何内置方法。 如果我想查找用户名以 A 或其他名称开头的所有用户,Finduserbyname 非常有用。
现在我需要一种有效的方法来逐页提取这些数据。
谢谢
I want to creating my own paging control and I would like to use it to list users in a grid.
Somehow I need to get only the top 10 for example users for the first page and then 10-20 users and so on.
I can't find any built in methods in the membership namespace. Finduserbyname is useful if I want to find all the users whose username starts for example with A or whatever.
Now I need a efficient way to pull these data on a page by page basis.
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当我用谷歌搜索方法定义 Membership.FindUsersByName 时,它有更多可用于定义分页的参数,
这是详细信息: http://msdn.microsoft.com/en-us/library/fa5st8b2.aspx
正如您从参数定义中看到的,您可以提供 (int) pageIndex,如以及(int)页面大小。
假设您总共有 100 条记录,这些记录符合名字 ='John' 的用户,那么如果您想检索第一页(每页总共 10 个用户),您可以设置 (int) pageIndex 为 1,然后 (int) pageSize 为 10。
随后,如果您想检索第二页,您可以将 (int) pageIndex 定义为 2,将 (int) pageSize 定义为 10。
您可以利用totalRecords (out)参数,获取总记录数,以便您可以使用它来显示在您的 UI Grid 中。
When i googled the method definition Membership.FindUsersByName, it has more parameters which can be used to defined Paging
Here is the details : http://msdn.microsoft.com/en-us/library/fa5st8b2.aspx
As you can see from the parameter definition, you can supply the (int) pageIndex, as well as the (int) pageSize.
so let's say you have a total of 100 records which qualified the users with firstname='John', then if you would like to retrieve the 1st page (with a total of 10 users in each page), you can set the (int) pageIndex to 1, and then the (int) pageSize to 10.
Subsequently if you want to retrieve the 2nd page, you can define the (int) pageIndex to 2 and (int) pageSize to 10.
You can utilize the totalRecords (out) parameter, to obtain how many total number of records , so that you can use this to display in your UI Grid.
我找到了一篇文章 显示如何使用 Membership.GetAllUsers(); 函数,然后将其用作数据源
因此,您有一个 gridview 或数据网格并像这样设置源:
然后您可以从那里创建分页(或使用 gridview 的内置分页)
I found an article that shows how to use the Membership.GetAllUsers(); function and then use that as a datasource
So, you have a gridview or data grid and set the source like so:
and then you can create your paging from there (or using built in paging from gridview)