Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 325575
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:13:46+00:00 2026-05-12T09:13:46+00:00

I cannot get the pager to work for my ListUsers page. The method in

  • 0

I cannot get the pager to work for my ListUsers page. The method in my controller looks like:

public ActionResult ListUsers(int? page, int? pageSize) {   
    int totalItems;
    var members = Membership.GetAllUsers(page ?? 1, pageSize ?? 50, out totalItems);
    ViewData["Users"] = ToList<MembershipUser>(members);
    return View();
}

And my aspx page has the following looks like:

<% var users = ViewData["Users"] as List<MembershipUser>; %>

<% foreach( var user in users ){ %>
           Email is: <%= user.Email %>
<% } %>

<%= Html.Pager((IPagination)ViewData["Users"])%>

I get the error

“Unable to cast object of type ‘System.Collections.Generic.List`1[System.Web.Security.MembershipUser]’ to type ‘MvcContrib.Pagination.IPagination’.”

What am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T09:13:46+00:00Added an answer on May 12, 2026 at 9:13 am

    I am not using Html.Grid within my view. I got it to work, but not sure if this is the best way code. Here it is:

    (my controller)

    public ActionResult ListUsers(int? page, int? pageSize) {

    int totalItems;
    var members = Membership.GetAllUsers(page ?? 0, pageSize ?? 50, out totalItems);
    ViewData["Users"] = ToList(members);
    // a second variable
    var members2 = Membership.GetAllUsers();
    ViewData["Users2"] = ToList(members2).AsPagination(page ?? 1, 50);
    return View();
    }

    (my view)

    
    <%  var users = ViewData["Users"] as List; %>

    <% foreach( var user in users ){ %>
    UserName: <%= user.UserName %>
    Email: <%= user.Email %>
    <% } %>
    //the pager
    <%= Html.Pager("Users2")%>

    Update: Paging is off by 1. Clicking "next" from the default page will skip a page. How do I fix this? The .AsPagination() method does not accept 0 AND starting .GetAllUsers() at 1 will not show the actual first page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have followed these instructions exactly, yet I get a Page cannot be found
I cannot get Bindable LINQ to work with VB.NET for the life of me.
I cannot get the jQuery slideDown function to work on <table> elements. They just
for some reason I cannot get any form to work correctly on my website,
For some reason I cannot get the error logging to work, I'm getting the
Here is what i cannot get to work - in mouseMove this.mouseX is undefined.
I cannot get text-overflow: ellipsis; to work... Maybe someone can give ma some help
I just for the life of me cannot get an AJAX call to work
Having done everything I have found I still cannot get Razor Intellisense to work
I cannot get this modal dialog to work property. Problem is that in a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.