Asp.net 成员中的分页有问题

Having issue with paging in Asp.net Membership

我正在使用以下代码:

  MembershipUserCollection users = Membership.GetAllUsers(page, pageSize, out totalRecords);
        if (users != null)
        { //DO STUFF}

问题是我没有得到预期的结果,因为给定值:

Page=2
pageSize=3

即使 totalrecord=8 .

我也只看到 2 条记录可以使用

请参阅附图以便更好地理解:

在上面你可以清楚地看到问题....

您使用了错误的重载。

public static MembershipUserCollection GetAllUsers(
    int pageIndex,
    int pageSize,
    out int totalRecords
);

使用此重载,您将查询 PageSize 为 3 的第 3 页上的用户。这将 return 只有两个用户。即,用户 7 和 8。

尝试使用,

public static MembershipUserCollection GetAllUsers();

如果您想对用户实施自定义分页,请参阅此 MSDN link:https://msdn.microsoft.com/en-us/library/dy8swhya(v=vs.110).aspx#exampleToggle