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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:43:14+00:00 2026-06-13T13:43:14+00:00

Alright so when the web part loads I pull from a list like so

  • 0

Alright so when the web part loads I pull from a list like so in the CreateChildControls() function:

String userGroup = GetProfileProperty(SPContext.Current.Web.CurrentUser.LoginName);//get user login's newsgroup // "All";

        if (!string.IsNullOrEmpty(userGroup) && !userGroup.Equals("All"))
        {
            qry.RowLimit = 5;
            camlquery = "<Where><Contains><FieldRef Name='Intended_x0020_Audience' /><Value Type='MultiChoice'>" + userGroup + "</Value></Contains></Where><OrderBy><FieldRef Name='Start_x0020_Date' Ascending='False' /></OrderBy>";
            qry.Query = camlquery;
            items = newsList.GetItems(qry);
            //Print items inside a ajax panel....


        }
        else
        {
            qry.RowLimit = 5;
            camlquery = "<OrderBy><FieldRef Name='Start_x0020_Date' Ascending='False' /></OrderBy>";
            qry.Query = camlquery;
            items = newsList.GetItems(qry);
            ////Print items inside a ajax panel....
        }

I do not use paging yet, but I have stored the query list in a var items. When the user clicks a button the update panel clears out the current controls and does another query to get the new items, but this time I use paging.(see below)

        int lastID = items[items.Count - 1].ID;//last news item id of current page

        //Get Web Context
        SPWeb web = SPContext.Current.Web;

        //Clear old panel
        UpdatePanel up = (UpdatePanel)FindControl("Panel");
        up.ContentTemplateContainer.Controls.Clear();//clear container of old news items

        SPQuery qry = new SPQuery();//get query

        qry.RowLimit = 5;
        string camlquery = "<OrderBy><FieldRef Name='Start_x0020_Date' Ascending='False' /></OrderBy>";
        qry.Query = camlquery;
        SPListItemCollectionPosition position = new SPListItemCollectionPosition("Paged=TRUE&p_ID=" + lastID.ToString());
        qry.ListItemCollectionPosition = position;
        items = web.Lists["News Wire"].GetItems(qry);// newsList.GetItems(qry);

        //print items inside ajax panel....

It does change the page, but it returns more items than necessary. I’ll get five when the webpart first loads, but when I click the button that triggers the event to get more list records, I get the first item of the next page and also the first page’s first 3 items. Note: My list only has six items in it. I limited my RowLimit to 5, but when I load the second page I get 4 items and 3 from the first page.

  • 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-13T13:43:15+00:00Added an answer on June 13, 2026 at 1:43 pm

    If you’re paging forwards, you can pass the ListItemCollectionPosition from your first query’s results (SPListItemCollection) to the next query – you don’t have to mess about constructing it by hand.

    You’ll need to store it somewhere after you get the first set of results – I’ve used ViewState before, you could use a hidden control in the update panel as well.

    When you’re paging backwards, you do need to create the string as you are doing. You also need to include a key/value to indicate that you’re going backwards, and you need to include an indication of your sort. (You might be able to get this from the auto-generated forward-paging value.) (I think missing the sort is why your forwards paging isn’t working, too.)

    This is the resource I used when I was trying to get this working myself, although it’s a little hazy now.

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

Sidebar

Related Questions

Alright so I'm using Microsoft's Web Services and AJAX to get information from a
Alright, so, I've looked around on the web and it doesn't really look like
Alright I created some custom classes for my project sourced from this tutorial ,
Alright, here I am again trying to write code from scratch and I can't
Alright, so I've looked around the web and haven't been able to find what
Alright, so I'm building a web app that provides music information (i.e. info on
i'm having a problem with UIWebView auto-rotating. the web view straches alright but the
Within a HttpModule, I'd like to figure out which web method was called/intercepted and
Alright, so I've figured out how to connect to a web service (.NET 2.0
Alright let me explain my situation first: I am part of an organization that

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.