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

  • Home
  • SEARCH
  • 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 522143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:19:26+00:00 2026-05-13T08:19:26+00:00

I’ve been struggling with some code for a paging for a couple of days

  • 0

I’ve been struggling with some code for a paging for a couple of days (YES! days) now but can’t get it to work properly, probably because I don’t have any experience on this kind of problems yet.

the paging I’m trying to do should look something like this:

1 2 3 4 5 6 … 101

When i click on number 5 i would like it to display the numbers like this:

1 … 3 4 5 6 7 … 101

when I’m at the last couple of pages i want it to look similar to the first one:

1 … 96 97 98 99 100 101

The bold number is the page that you’re currently viewing.

I want the dots to appear only when there is more than 7 pages available, if not it should look like a normal paging would look like:

1 2 3 4 5 6 7

Right now i want to display 10 items per page.

The language i want to use is C# (ASP.NET) and would like to, later on make this a usercontrol (Where i should set the properties TotalNumberOfItems, ItemsPerPage and so on).

The question:
How do i write the code to loop out the numbers on the correct places? 🙂

  • 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-13T08:19:26+00:00Added an answer on May 13, 2026 at 8:19 am

    How about (Make it Bold is somewhat psuedoCode cause I don’t know what UI you’re in…)

       private static string BuildPaging(int pageNo, int pageCount)
       {
          StringBuilder sb = new StringBuilder();
    
          for(int i = 1; i < pageCount; i++)
          {
             if (i == pageNo) 
                 sb.Append([Make it Bold] + i.ToString("0") + [Make it not Bold]);
             else if (1 > pageNo - 3 && i < pageNo + 3)
                 sb.Append(i.ToString("0"));
             else if ((i == 2 && pageNo > 4) ||        
                      (i == PageCount - 1 && pageNo < PageCount - 2))
                 sb.Append("...");
          }
          return sb.ToString();
       }
    

    Only thing is how to make it bold (Depends on whether you’re in WinForms or ASP.Net…
    … And add stuff to make it a clickable link…

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6
I have a bunch of posts stored in text files formatted in yaml/textile (from
We're building an app, our first using Rails 3, and we're having to build
I am trying to loop through a bunch of documents I have to put
I'm making a simple page using Google Maps API 3. My first. One marker

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.