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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T14:15:15+00:00 2026-06-07T14:15:15+00:00

I got 2 pages ASP.NET (PageA.aspx and PageB.aspx). Each Page can display muliple records

  • 0

I got 2 pages ASP.NET (PageA.aspx and PageB.aspx). Each Page can display muliple records (about 7000). Instead of showing all 7000 records, I created my own navigation class that display the page number. (Page#1 = record 1 to 100; Page#2 = record 101 to 200 etc..).

When the PageA loads, I call an instance (singleton) of my navigation class. This way I’m not loosing the current Page#. The problem is that if I’m at page #6 and move to the PageB.aspx, because I created an instance, PageB.aspx start at Page#6. I’d like to set the current page to 1 in Page_Load, but as I can see, Page_Load is called evrytime something change in my page 🙁

What’s the best way of doing this?

Here’s my PageA.aspx as example

protected void Page_Load(object sender, EventArgs e)
{
    navigation = NavigationPage.getInstance();
    loadItems();
}

private void loadItems()
{
    ArrayList arItems = soldJobsDAO.GetQuotesToShow();
    loadPageNavigation(arItems.Count);
    // Start Table Headers
    // ...
    // End Table Headers
    int min = navigation.minPage > arItems.Count ? 0 : navigation.minPage;
    int max = navigation.maxPage > arItems.Count ? arItems.Count : navigation.maxPage;
    for (int i = min; i < max; i++)
    {
        SoldJobs job = (SoldJobs)arItems[i];
        // Start Table Rows
        // Start Table Cells
        // End Table Cells
        // End Table Rows
    }
}

private void loadPageNavigation(int maxValue)
{
    PageNavigation.Controls.Clear();
    ArrayList NavDiv = navigation.getNavigationPage(maxValue);
    for(int i = 0; i < NavDiv.Count; i++)
    {
        PageNavigation.Controls.Add((LinkButton)NavDiv[i]);
    }
}

Here’s the Navigation class

namespace HomeSite.Class
{
    public class NavigationPage
    {
        private static NavigationPage navigation;
        private int m_currentPage;
        private int m_minPage;
        private int m_maxPage;
        private const int NB_ITEM_PER_PAGE = 15;

        private NavigationPage()
        {
            currentPage = 1;
        }

        public static NavigationPage getInstance()
        {
            if (navigation == null) 
            {
                navigation = new NavigationPage();
            }
            return navigation;
        }

        public int currentPage
        {
            get
            {
                return m_currentPage;
            }
            set
            {
                m_currentPage = value;
                maxPage = currentPage * NB_ITEM_PER_PAGE;
                minPage = maxPage - NB_ITEM_PER_PAGE;
            }
        }

        public int minPage
        {
            get
            {
                return m_minPage;
            }
            set
            {
                m_minPage = value;
            }
        }

        public int maxPage
        {
            get
            {
                return m_maxPage;
            }
            set
            {
                m_maxPage = value;
            }
        }

        public int getNumberItemPerPages
        {
            get
            {
                return NB_ITEM_PER_PAGE;
            }
        }

        public ArrayList getNavigationPage(int maxValue)
        {
            ArrayList arItems = new ArrayList();
            int maxNbPagesToDisplay = 11;
            int nbPages = 1;
            if (maxValue > 0)
                nbPages = maxValue / getNumberItemPerPages + 1;

            if (nbPages != 1)
            {
                LinkButton link;

                // We want the current page to be centered if possible
                int FirstPageDisplayed = currentPage - (maxNbPagesToDisplay/2);
                if (FirstPageDisplayed < 1)
                    FirstPageDisplayed = 1;
                int LastPageDisplayed = FirstPageDisplayed + maxNbPagesToDisplay - 1;
                if (LastPageDisplayed > nbPages)
                    LastPageDisplayed = nbPages;

                for (int i = (FirstPageDisplayed - 1); i <= (LastPageDisplayed - 1); i++)
                {
                    int PageNumber = i + 1;

                    link = new LinkButton();
                    link.ID = "Page" + PageNumber.ToString();
                    link.Text = PageNumber.ToString();
                    link.CommandArgument = PageNumber.ToString();
                    //link.Command += LinkButton_SetCurrentPage;
                    link.Style.Add("font-size", "14px");
                    arItems.Add(link);
                }
            }
            return arItems;
        }
    }
}
  • 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-06-07T14:15:16+00:00Added an answer on June 7, 2026 at 2:15 pm

    You are likely to run into other problems with this approach. The simplest scenario that I can think of would be when you have more than one user accessing your pages at one time.

    In order to keep state like this, you need to either:

    • Store your navigation state in the ViewState (using the Session would cause the same problem across multiple pages for the same user)
    • Place the current page in a hidden field so that the browser sends it back on each request

    I would recommend the latter, it is closer to the stateless form of the web.

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

Sidebar

Related Questions

I've got a set of ASP.Net pages that display a number of asp:TextBox fields
Got a project with standard Asp.Net (aspx) pages running alongside MVC 3 Razor controllers/views.
I've got several pages on my ASP.NET MVC 3 website (not that the technology
In asp.net web page got username, password, emailid from login page using session. In
I'm working on an ASP.NET page where I've got 10 entities. I'll call them
I've got a regular ASP.NET web form page and am pasting in a <%=
I have a ASP.NET page what I got at the moment is <%@ Page
I just got a couple questions about asp.net mvc 3. I was reading about
I am working in C#(asp.net). I have two pages 'abc.aspx' and 'xyz.aspx'. I want
I've got a Repeater that lists all the web.sitemap child pages on an ASP.NET

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.