Note that there are some explanatory texts on larger screens.

plurals
  1. POUnexpected results when using .net ajax & paging in sharepoint web part with c#
    primarykey
    data
    text
    <p>Alright so when the web part loads I pull from a list like so in the CreateChildControls() function:</p> <pre><code>String userGroup = GetProfileProperty(SPContext.Current.Web.CurrentUser.LoginName);//get user login's newsgroup // "All"; if (!string.IsNullOrEmpty(userGroup) &amp;&amp; !userGroup.Equals("All")) { qry.RowLimit = 5; camlquery = "&lt;Where&gt;&lt;Contains&gt;&lt;FieldRef Name='Intended_x0020_Audience' /&gt;&lt;Value Type='MultiChoice'&gt;" + userGroup + "&lt;/Value&gt;&lt;/Contains&gt;&lt;/Where&gt;&lt;OrderBy&gt;&lt;FieldRef Name='Start_x0020_Date' Ascending='False' /&gt;&lt;/OrderBy&gt;"; qry.Query = camlquery; items = newsList.GetItems(qry); //Print items inside a ajax panel.... } else { qry.RowLimit = 5; camlquery = "&lt;OrderBy&gt;&lt;FieldRef Name='Start_x0020_Date' Ascending='False' /&gt;&lt;/OrderBy&gt;"; qry.Query = camlquery; items = newsList.GetItems(qry); ////Print items inside a ajax panel.... } </code></pre> <p>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)</p> <pre><code> 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 = "&lt;OrderBy&gt;&lt;FieldRef Name='Start_x0020_Date' Ascending='False' /&gt;&lt;/OrderBy&gt;"; qry.Query = camlquery; SPListItemCollectionPosition position = new SPListItemCollectionPosition("Paged=TRUE&amp;p_ID=" + lastID.ToString()); qry.ListItemCollectionPosition = position; items = web.Lists["News Wire"].GetItems(qry);// newsList.GetItems(qry); //print items inside ajax panel.... </code></pre> <p>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. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload