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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:13:49+00:00 2026-05-28T18:13:49+00:00

DataPager has some strange behavior. So to situate the problem, I have a DataPagerReapeater

  • 0

DataPager has some strange behavior.

So to situate the problem, I have a DataPagerReapeater with information. And I have a DataPager,
which I made to work together. I have 3 pages, but DataPager has some strange behavior.

When I’m on the first page and I click next it goes to 2nd, everything is fine. When I click next again it does a postback but doesnt move to the 3rd page. Last and first also works fine.

But when I’m on the second page and I click next it will not move to the third page, but stays on the second. Same if I manually click on the third page and click previous, it goes to the first page.

I really dont understand why.

Here is the DataPager:

<asp:DataPager ID="DataPager1" PagedControlID="ReapeaterCSGator" PageSize="5" 
        runat="server" onprerender="DataPager1_PreRender">
    <fields>
            <asp:NextPreviousPagerField ButtonType="Link" ShowFirstPageButton="True"  FirstPageText="<< First"
            ShowNextPageButton="False" ShowPreviousPageButton="False" />
        <asp:NextPreviousPagerField ButtonType="Link" ShowFirstPageButton="False"  FirstPageText="< Previous"
            ShowNextPageButton="False" ShowPreviousPageButton="True" />
        <asp:NumericPagerField />
        <asp:NextPreviousPagerField ButtonType="Link" ShowLastPageButton="False"  LastPageText="Next >"
            ShowNextPageButton="True" ShowPreviousPageButton="False" />
        <asp:NextPreviousPagerField ButtonType="Link" ShowLastPageButton="True"  LastPageText="Last >>"
            ShowNextPageButton="False" ShowPreviousPageButton="False" />
    </fields>
</asp:DataPager>

Here is the code which I execute on PreRender:

protected override void OnPreRender(EventArgs e)
{
    base.OnPreRender(e);

    IEnumerable<CollaborativeSpace> listCS = LoadCollaborativeSpaces();
    // Binding the repeater with the list of documents
    ReapeaterCSGator.DataSource = listCS;
    ReapeaterCSGator.DataBind();

}

So, the behavior is really strange and I have no idea what the problem could be.

Anyone else confronted such an issue?

UPDATE: Here is on load method and what i have in there:

        ResultPerPages = GetResultsPerPage();
        DataPager2.PageSize = ResultPerPages;
        DataPager1.PageSize = ResultPerPages;
        //We initialize the pager repeater with the same value
        ReapeaterCSGator.SetPageProperties(0, ResultPerPages, false);
        //We add an handler on item data bound event for sub repeater
        ReapeaterCSGator.ItemDataBound += ReapeaterCSGator_ItemDataBound;
        //If the user is not post backing
        if (!IsPostBack)
        {
            //We add choices on drop down list "Results per page"
            foreach (int choice in NbResultsChoices)
            {
                NbResultsPerPage.Items.Add(new ListItem(choice + " results per page", choice.ToString(CultureInfo.InvariantCulture)));
            }
            //We get collaborative spaces from Sharepoint list
            //IEnumerable<CollaborativeSpace> listCS = LoadCollaborativeSpaces();
            //// Binding the repeater with the list of documents
            //ReapeaterCSGator.DataSource = listCS;

UPDATE 2:
Here is the code behind SetPageProperties()

 public void SetPageProperties(int startRowIndex, int maximumRows, bool databind)
    {
        ViewState["_startRowIndex"] =startRowIndex;
        ViewState["_maximumRows"] = maximumRows;
        if (TotalRows > -1)
        {
            if (TotalRowCountAvailable != null)
            {
                TotalRowCountAvailable(this, new PageEventArgs((int)ViewState["_startRowIndex"], (int)ViewState["_maximumRows"], TotalRows));
            }
        }
    }

That component was used form here: http://www.codeproject.com/Articles/45163/Extend-Repeater-to-support-DataPager

PROBLEM SOLVED, it seems that the datapagerrepeater wasnt implemented the right way, now that i found the sources i could fix it. Thanks anyways for the help

  • 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-28T18:13:49+00:00Added an answer on May 28, 2026 at 6:13 pm

    If I read your load method right, you’re resetting the repeater to page 1 on every Page_Load.

    What happens is:

    • In Page_Load, you reset the repeater to page 1 in the SetPagerProperties() call
    • During the control event dispatch phase, the datapager is advanced to the next page relative to page 1:
      • if you use “first” and “last” and specific pages, everything works, because they’re not relative changes
      • “next” goes to the page after page 1, which is why you’re stuck on page 2,
      • “previous” tries to go to the page before 1, since there is none, it stays on 1.

    To fix this, stop initialising the pager on every page load. Either get rid of the call – I’m not sure why it’s there, I only use it to “reset” the repeater, for example after a user clicks a column header to sort a list view. Or move it into the if (!IsPostback) block.

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

Sidebar

Related Questions

I have a strange problem that I don't understand about DataPager. After changing the
I'm experimenting with the Silverlight 4 SDK DataPager. I have some code in my
I have an asp:ListView control which list playlists. It has paging supported and holds
In my asp.net page I have a listview that has a datapager defined in
I have a Silverlight application that has a DataGrid and a DataPager. The data
Possible Duplicate: simple DataGridView refresh question I have a mainForm which has a DataGridView
I have a problem with DataPager with ListView, I am using ASP.NET with VB.NET.
I have a datapager with a pagertemplate. In the template I have a Show
I have problem with copying sdf file to WM emulator. My solution structure MyApp.DataLayer
Let me define the problem first and why a messagequeue has been chosen. I

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.