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 7634541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:12:11+00:00 2026-05-31T07:12:11+00:00

I am looking for the best way to implement a pager as per the

  • 0

I am looking for the best way to implement a pager as per the following simple requirement.

I want a page like this

 <Pager 1 2 3 4 ...>

 <Partial View>

My action controller will look something like this…

    public PartialViewResult DisplayRecordDetails(int recordNumber)
    {
        MyRecord mr = GetRecord(recordNumber);
        return PartialView(mr);
    }

When I click on “1” (page index = 1), I pass 1 as a parameter to the DisplayRecordDetails action method and load the partial view with record 1.

When I click on “2” (page index = 2), I pass 2 as a parameter to the DisplayRecordDetails action method and load the partial view with record 2 and so on…

I will have the total item count info and current page index info at my disposal. Now how can I generate the pager dynamically with this info?

I have tried searching for pager libraries/helpers but all of them are for grids. How can I use them for my situation? I do not have a grid. I just have a partial view which I need to load dynamically depending on the page number.

  • 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-31T07:12:12+00:00Added an answer on May 31, 2026 at 7:12 am

    You could design a view model which will contain all the id numbers:

    public class MyViewModel
    {
        // the currently selected id
        public int Id { get; set; }
    
        // a list of available ids
        public int[] Ids { get; set; }
    }
    

    And then have a controller action which will query your database or whatever and fetch the list of all available ids:

    public ActionResult Index(int? id)
    {
        var model = new MyViewModel
        {
            Id = id ?? 0,
            Ids = new[] { 563, 845, 845 } // those will come from your datasource
        };
        return View(model);
    }
    

    and in the corresponding view you could loop through those ids and generate links:

    @model MyViewModel
    <div>
        @Html.Action("DisplayRecordDetails", new { recordNumber = Model.Id })
    </div>
    @for (var i = 0; i < Model.Ids.Length; i++) 
    {
        <span>@Html.ActionLink((i + 1).ToString(), "Index", new { id = i })</span>
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for the best way to implement this in ASP.NET. On the page,
I'm looking for the best way to implement the following. I have a MySQL
I'm looking for a best way to implement common Windows keyboard shortcuts (for example
Looking for some advice on the best way to implement localization along with client
What's the best way to implement the enum idiom in Ruby? I'm looking for
I'm looking for the best way to take a simple input: echo -n Enter
I looking for the best way to implement a block that lists all terms
I am looking about the best way to implement a multi-sites replication with MySDQL.
I'm looking for the best way to implement data transfer to and from an
I'm looking for some advice on the best way to implement the task below

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.