Paging SPGridView with SPListItemCollectionPosition

HI,
I am using the SPGridView, SPGridViewPager in a visual webpart. In the visual webpart, I have two custom webpart properties -
named "Items to show, PagingNumber ". If the "Items to show" is less than 10, then paging is not required. "Paging number" is a dropdown enum which contains 10, 50, 100.
I want to use the "SPListItemCollectionPosition" to page through the items in gridview. How to use it, when using a custom page number?
I have tried the below, but the paging controls are not shown:
<div id="div1" >
<SharePoint:SPGridView runat="server" ID="Gridview1" AutoGenerateColumns="false" AllowPaging="true" PageSize="10">
<Columns>
<asp:TemplateField HeaderText="Titles">
<ItemTemplate>
<asp:Label ID="lblTitle" Text='<%# Eval("Title") %>' runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerSettings Mode="NextPreviousFirstLast" Visible="true" NextPageText="Next |" PreviousPageText="Previous |" FirstPageText="First |" LastPageText="Last" />
</SharePoint:SPGridView>
</div>
<div id="TestPager" >
<SharePoint:SPGridViewPager ID="Grid1Pager" runat="server" GridViewId="Gridview1">
</SharePoint:SPGridViewPager>
</div>
In the cs code:
public void BindGridView()
using (SPSite oSite = new SPSite(SiteName))
using (SPWeb oWeb = oSite.OpenWeb())
SPList lstPages = oWeb.Lists["Pages"];
SPQuery sQuery = new SPQuery();
var ItemsPerpage = PagingItem.ToString();
if (ItemsPerpage == "Fifty" )
sQuery.RowLimit = 50;
else if (ItemsPerpage == "Hundred")
sQuery.RowLimit = 100;
else
sQuery.RowLimit = 10; // default Paging is set for 10
sQuery.Query = "<Where><Eq><FieldRef Name='_ModerationStatus'/><Value Type='ModStat'>0</Value></Eq></Where>";
sQuery.ViewFields = string.Concat("<FieldRef Name='Title' />","<FieldRef Name='EncodedAbsUrl' />");
sQuery.ViewFieldsOnly = true;
DataTable dt = new DataTable();
SPListItemCollection myColl = lstPages.GetItems(sQuery);
if (myColl.Count > 0)
dt = myColl.GetDataTable();
do
Gridview1.DataSource = dt;
Gridview1.DataBind();
sQuery.ListItemCollectionPosition = myColl.ListItemCollectionPosition;
} while (sQuery.ListItemCollectionPosition != null);
Not sure, why the pager is not showing. Total number of records is 110. Rowlimit is 10, so I am expecting Pager.
How to fix this?
Thanks

We need to save the current page info in the view state.
Please refer below links
http://www.codeproject.com/Articles/407558/SharePoint-using-SPListItemCollectionPosition
http://ajamaeen.blogspot.in/2013/02/paging-with-splistitemcollectionposition.html
http://blog.techperspect.com/2011/03/step-by-step-guide-to-implement-paging.html

Similar Messages

  • SPGridView with filtering on Taxonomy Field Multivalue column( column with multiple values in single row)

    Hi
    I have SPGridView  control (fetching value from DB) with a column which is having multiple values
    in single row seperated by ";", whenever filter applied it show these values in single row but i want
    to dispaly these values separately in diff. rows when column filter is applied.
    I have exactly same req. as mentioned in http://sadomovalex.blogspot.in/2011/03/spgridview-with-filtering-by-multiple.html
    but this solution didn't work for me.
    Please help/suggest.

    Hi Erland,
    Thank you very much for the answer. Sorry I had to be more accurate on my XML : This XML is in a SQL Server Table column. This table also has an id column. It will be great if you can answer specifically to this.
    <RootNode>
    <Node1>
    <Line_id_Node>1 </Line_id_Node>
    <A>
    <B>
    <D>Val1 </D>
    </B>
    <B>
    <D>Val2 </D>
    </B>
    <B>
    <D>Val3 </D>
    </B>
    </A>
    </Node1>
    <Node1>
    <Line_id_Node> 2 </Line_id_Node>
    <A>
    <B>
    <D>Val4 </D>
    </B>
    <B>
    <D>Val2 </D>
    </B>
    </A>
    </Node1>
    <Node1>
    <Line_id_Node> 3 </Line_id_Node>
    <A>
    <B>
    <D>Val5 </D>
    </B>
    </A>
    </Node1>
    </RootNode>
    Expected O/P:
    Line_id_Node                Column_D
    1                                                                    1                                           
    val1, val2, val3
    2                                                                    2                                               
    val4, val2
    3                                                                    3                                                  
    val5
    Nichesl

  • How do I delete partially installed apps. I erased iPad and installed iOS8. I installed new apps. Suddenly all paged populated with old apps that never install and I can not delete.

    How do I delete partially installed apps. I erased iPad and installed iOS8. I installed new apps. Suddenly all paged populated with old apps that never install and I can not delete.

    Hi Try a Reboot press power & menu button hold both down until you see the Apple Logo you will not lose any data But you me need to do this more than once. Cheers Brian

  • Valcom 2001A single zone paging system with a Cisco 2821 FXS port

    I am new at troubleshooting the Valcom paging system with Cisco 2821 router.  I recently installed a Valcom 2001A that is connecting to FXS port on the Cisco router.  The paging works but the ringing does not stop when the page extension is dialed (you can talk over the ringing).  I was told to use the Valcom 9970 to work with the FXS port on my router.  Will the V9970 worth with the 2001A or in place of it?  Is there anything else I need to know to perfect this install?  Thank you! 

    Put the command 'forward-digits extra ,,,,01' on the outgoing POTS dial-peer. Each comma is one second of delay.

  • Paging problem with Crystal Report Viewer in VS 2013

    I am attempting to upgrade a VS 2008 project that uses a dozen plus Crystal Reports to display data for our owners.
    The problem that i am having is with navigating to other pages of any multiple page report using the paging buttons of the Report Viewer control. The report will load fine and display the first page. If I try and go to page two an overlay covers the screen and a progress graphic displays and will never go away.  I have to stop debugging the project and restart it.  I have been able to get the paging buttons to work if I click on one of the asp.net buttons that I have added to the page that run the .ShowFirstPage(), .ShowNextPage();.ShowPreviousPage(); or .ShowLastPage(); methods of the ReportViewer control.  When in click on one of these buttons an error displays within the ReportViewer control that reads simply "ERROR". From there I can click on one of the asp.net button described above and the report displays and at this time the navigation buttons work as expected.
    The parameters are being set via a series of asp controls and then stored in ViewState then passed to the ParameterFieldInfo of the ReportViewer control.
    This all works just fine in VS 2008 project but I have not been able to resolve the paging issue since upgrading.
    Does anyone have any ideas as two what may be causing this behavior?

    Thanks for your reply.
    I am on SP 9.
    I moved the block assigning the report source of the ReportViewer to the Page_Init method, but that did not change anything.
    The reports are loaded when the user clicks on a link button specifying the report that they wish to view.  In the click event of the button a method is called to set the LogOnInfo for each table of the reportsource;
    Tables  tables = reportSource.ReportDocument.Database.Tables;
    foreach ( CrystalDecisions.CrystalReports.Engine.Table table in tables ) {
    var logonInfo = table.LogOnInfo;
    logonInfo.ConnectionInfo = connectionInfo;
    table.ApplyLogOnInfo( logonInfo );
    Then all the parameters are set;
    crvReportViewer.Visible = true;
    crvReportViewer.ParameterFieldInfo.Clear();
    SetDateValuesForParameterFields();
    SetEquipClassValuesForParameterFields();
    crvReportViewer.ParameterFieldInfo = paramFields;
    crvReportViewer.ParameterFieldInfo.AddRange( equipClassParamFields );
    Session[ "CurrentReportSource" ] = crvReportViewer.ReportSource;
    Then in the Page_Init I assign the ReportSource of the ReportViewer control;
        if (Session["CurrentReportSourceId"] != null)
    crvReportViewer.ReportSource = Session["CurrentReportSource"];
    And in Page_Load;
    if ( Page.IsPostBack ) {
                    ApplicationSettings appSettings = AppConfigSettings.LoadSettings();
    connectionInfo.ServerName = appSettings.PrimarySettings.Server;
    connectionInfo.DatabaseName = appSettings.PrimarySettings.DataSource;
    connectionInfo.UserID = appSettings.PrimarySettings.UserId;
    connectionInfo.Password = appSettings.PrimarySettings.Password;
    startDate.Name = "StartDate";
    endDate.Name = "EndDate";
    trailerNumber.Name = "TrailerNumber";
    location.Name = "LocationId";
    equipClass.Name = "EquipClass";
    txtStartDate.Focus();
    When in run this the reports will populate and display the first page but if I try to navigate to another page I get a error;
    Unhandled exception at line 12, column 82761 in http://localhost:63034/aspnet_client/system_web/4_0_30319/crystalreportviewers13/allInOne.js
    0x800a138f - Java Script runtime error: Unable to get property 'length' of undefined or null reference
    And on the screen there is a wait spinner.
    This all works fine in the VS2008 project.
    Thanks,
    Shannon

  • Can't get paging working with asp(vb)

    Hello,
    Anyone out there who has experience with 'httpservice paging' and a asp(vb) backend?

    Deleted
    Last edited by impassive (2011-08-27 15:15:27)

  • Paging record with sql server

    i'd like to paging my web with jsp and my database is sql server. as far as i know, to paging record in jsp are use 'LIMIT' but sql server does not support that. this syntax is only for MySQL. How to paging record but with sql server as database...please help me..???

    I would say the best solution is this:
    dont use sql server.
    Humour aside, did u look on msdn ? Oracle has "where rownum <10" and some other databases use "select first 10" type syntax. I'm sure its on the m$ website...

  • WebPart: Display the search result in an spgridview with filter and sort

    hi,
    For explain more in details.
    I need the search result in a table displaying some meta common in the different library.
    I've to have the possibility to filter and sort the grid.
    i'm trying to extend Microsoft.Office.Server.Search.WebControls.CoreResultsWebPart
    i can have the result from the textbox search with: SharedQueryManager.GetInstance(this.Page).QueryManager
    My queryManager is populate in the method: CreateChildControls
    I put the sample code i use. and in the populateData method, my querymanager is null while in the createChildContriol, it's correctly populate with : this.queryManager = SharedQueryManager.GetInstance(this.Page).QueryManager;
    using System;
    using System.ComponentModel;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using Microsoft.SharePoint;
    using Microsoft.SharePoint.WebControls;
    using Microsoft.SharePoint.Search.Internal.WebControls;
    using Microsoft.Office.Server.Search.Query;
    using Microsoft.Office.Server.Search.WebControls;
    using System.Data;
    using System.Xml;
    namespace CustomSearchResultWebPart.CustomCoreResultWebPart
    [ToolboxItemAttribute(false)]
    public class CustomCoreResultWebPart : Microsoft.Office.Server.Search.WebControls.CoreResultsWebPart
    private ObjectDataSource objDS;
    private const string ObjectDataSourceID = "gridViewDataSource";
    private QueryManager queryManager;
    private SPGridView gridView = new SPGridView();
    protected override void CreateChildControls()
    //here is correctly populate
    this.queryManager = SharedQueryManager.GetInstance(this.Page).QueryManager;
    try
    LoadSearchGrid();
    catch (Exception ex)
    Page.Response.Write(ex.Message + " - " + ex.StackTrace);
    //base.CreateChildControls();
    protected override void OnInit(EventArgs e)
    base.OnInit(e);
    protected override void OnLoad(EventArgs e)
    base.OnLoad(e);
    protected override void OnPreRender(EventArgs e)
    //gridView.DataBind();
    base.OnPreRender(e);
    protected override void Render(HtmlTextWriter writer)
    base.Render(writer);
    public DataTable populateData()
    DataSet dtSet = null;
    DataTable dtTable = null;
    //here is my query manager is null
    if (queryManager != null && queryManager.Count > 0)
    XmlDocument xdoc = new XmlDocument(); //We are using XmlDocument
    xdoc = queryManager.GetResults(queryManager[0]);//xml returned by search
    if (xdoc != null)
    XmlReader xmlReader = new XmlNodeReader(xdoc);
    dtSet = new DataSet();
    dtSet.ReadXml(xmlReader);
    if (dtSet.Tables.Count > 1)
    dtTable = dtSet.Tables["Result"];
    return dtTable;
    private void LoadSearchGrid()
    this.objDS = new ObjectDataSource();
    this.objDS.ID = ObjectDataSourceID;
    this.objDS.SelectMethod = "populateData";
    this.objDS.TypeName = this.GetType().AssemblyQualifiedName;
    this.objDS.ObjectCreating += new ObjectDataSourceObjectEventHandler(objDS_ObjectCreating);
    this.Controls.Add(objDS);
    gridView.ID = "_gridView";
    gridView.AutoGenerateColumns = false;
    gridView.Width = new Unit(100, UnitType.Pixel);
    gridView.EnableViewState = false;
    gridView.AllowPaging = true;
    gridView.PageSize = 5;
    gridView.DataSourceID = ObjectDataSourceID;
    this.Controls.Add(gridView);
    void objDS_ObjectCreating(object sender, ObjectDataSourceEventArgs e)
    //e.ObjectInstance = objDS;
    protected void gridView_RowDataBound(object sender, GridViewRowEventArgs e)
    //throw new NotImplementedException();
    Do you have a sample that i can use or some tutorial?
    thanks for your help

    I added this in my class
    public class CustomResultsDatasource : CoreResultsDatasource
    public CustomResultsDatasource(Microsoft.Office.Server.Search.WebControls.CoreResultsWebPart parentWebPart)
    : base(parentWebPart)
    View = new CustomResultsDatasourceView(this, GetType().Name);
    public class CustomResultsDatasourceView : CoreResultsDatasourceView
    public CustomResultsDatasourceView(SearchResultsBaseDatasource dataSourceOwner, string viewName)
    : base(dataSourceOwner, viewName)
    //make sure we have a value for the datasource
    if (DataSourceOwner == null)
    throw new ArgumentNullException("DataSourceOwner");
    CustomResultsDatasource datasource = this.DataSourceOwner as CustomResultsDatasource;
    this.QueryManager = SharedQueryManager.GetInstance(datasource.ParentWebpart.Page).QueryManager;
    And this in my customSearchResultWebPart
    protected override void CreateDataSource()
    //base.CreateDataSource();
    this.DataSource = new CustomResultsDatasource(this);
    How can i use queryManager in populateData?
    thanks for your help

  • Paging setup with HT503 and Bogen system

    We have to setup a Bogen Paging system using a HT503 ATA device in local GW FXS port for CUCM.
    Please provide an understandding on how this is gonna setup.
    It will have multizone paging i.e. if you press different number it will page out different zone.
    Generally we create a Route pattern which will go to the gateway and activate the FXS port.

    OK, first of all, you will not be connecting the FXS port of the 2921 to the HT503.  The HT503 LAN port need to be on your LAN and you need to configure it as a SIP gateway.  The 2921 is not needed to access the Bogen.
    A multi-zone paging adaptor needs to use a trunk port. Correction: most multi-zone paging adaptors need a trunk port; It is possible (which means someone has done it) to configure a paging adaptor on an FXS port that connects and then waits for a DTMF tone to select the zone.
    Based on the code you mentioned, I assume you are talking about a Bogen UTI312 unit, which does use an FXO port.  It needs an FXO port (i.e. trunk port) because it is expecting call setup signalling over the line.  That signalling would be the selected zone.  So the setup here would be the CUCM has a route pattern that sends the Bogen code (i.e. *01) as the called number and routes the call to the HT503 gateway, which is setup as a SIP gateway in CUCM.  The SIP gateway on the HT503 is configured to route any call that starts with an '*' to the FXO port.  And finally the Bogen in connected to the FXO port of the HT503.
    HTH,
    Chris

  • InformaCast 8.3 Basic Paging fails with Were sorry no devices could be activated. Your broadcast will not be completed.

    I setup InformaCast 8.3 Basic Paging with CallManager 9.1 using SIP 7965 phones.  The 7965s are in a Recipient Group with a DialCast number setup for that Recipient Group;
    When I dial the CTI Route Point I hear;
    Welcome to the  Singlewire Informacast System...ding..ding
    Were sorry no devices could be activated. Your broadcast will not be completed.

    Amir,
    The resolution I found was to go to
    Admin || Dial Cast || Dialing Configurations || Recipient Groups
    and add an recipient group previously created under Recipients || Recipient Groups
    Restart the CTI route point in Call Manager that Informacast is using.
    I also spanned the port on the phone and did a packet capture to see if IGMPv2 packets were being received properly before and after the fix was implemented.

  • How do you set up Paged View with Spry Data Sets

    Hope someone can help. I have constructed a Spry data set using a html table and want  to use the paged view javascript to limit the amount of rows displayed on one page at a time to 10 then forcing a new page. Have found the java script file in the spry 1.6 download and attached it to the spry assets folder and have followed the instructions found at the Adobe development center   http://labs.adobe.com/technologies/spry/articles/pager/index.html        with no luck. Have attached  files to show what I have done. If someone could look at this and point out my error or suggest a better way I would be grateful. I am not a code warrior so simple  instructions would be so helpful. Many thanks in advance.
    Here is the code
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xmlns:spry="http://ns.adobe.com/spry">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Untitled Document</title>
    <script src="SpryAssets/SpryData.js" type="text/javascript"></script>
    <script src="SpryAssets/SpryHTMLDataSet.js" type="text/javascript"></script>
    <script src="SpryAssets/SpryPagedView .js"></script>
    <link href="SpryAssets/SpryMasterDetail.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
    <!--
    var ds1 = new Spry.Data.HTMLDataSet("table.html", "ds1", {sortOnLoad: "Name", sortOrderOnLoad: "ascending"});
    ds1.setColumnType("Phone", "number");
    var pv1 = new Spry.Data.PagedView( ds1 ,{pageSize: 10});
    //-->
    </script>
    </head>
    <body>
    <input type="button" value="First" onclick="pv1.firstPage();" />
    <input type="button" value="Prev" onclick="pv1.previousPage();" />
    <input type="button" value="Next" onclick="pv1.nextPage();" />
    <input type="button" value="Last" onclick="pv1.lastPage();" /
    <div class="MasterDetail">
      <div spry:region="ds1" class="MasterContainer">
        <div class="MasterColumn" spry:repeat="ds1" spry:setrow="ds1" spry:hover="MasterColumnHover" spry:select="MasterColumnSelected">{Name}</div>
      </div>
      <div spry:detailregion="ds1" class="DetailContainer">
         <div class="DetailColumn">{Name}</div>
        <div class="DetailColumn">{Product}</div>
        <div class="DetailColumn">{Contact}</div>
        <div class="DetailColumn">{Phone}</div>
      </div>
      <br style="clear:both" />
    </div>
    <input type="button" value="First" onclick="pv1.firstPage();" />
    <input type="button" value="Prev" onclick="pv1.previousPage();" />
    <input type="button" value="Next" onclick="pv1.nextPage();" />
    <input type="button" value="Last" onclick="pv1.lastPage();" /
    </body>
    </html>

    Your region needs to refer to the pageview, not the dataset.  Your paged view var is already looking at/pulling in the ds.
    I would change the following code:
    <div spry:detailregion="ds1" class="DetailContainer">
         <div class="DetailColumn">{Name}</div>
        <div class="DetailColumn">{Product}</div>
        <div class="DetailColumn">{Contact}</div>
        <div class="DetailColumn">{Phone}</div>
      </div>
    to read the following:
    <div spry:region="pv1">
    <table>
    <tr spry:repeat="pv1">
    <td>{Name}</td>
    <td>{Product}</td>
    <td>{Contact}</td>
    <td>{Phone}</td>
    </tr>
    </table>
    Regards,
    Michael

  • Error with paging action handler

    We are using the proposed action handler from Steve Muench's book for stateless paging to our highest confidence.
    The problem is that after some days the paging parameter p gets always a wrong value. We think it is the total rowcount, because we implemented a test-parameter.
    From then displaying a page starts always (?) with the last page. If this situation occurs it happens in different (!) applications, so it isn't a parameter side effect.
    There is not p session or cookie parameter who could override the silent work of the action handler.
    We are using the XSQL servlet 1.0.4.1 under Red Hat Linux 7.0 with an Oracle 8.1.7 database. Servlet container is Tomcat 3.2 with JDK 1.3 from Sun.
    Stopping Tomcat and restarting it solves the problem (for some time).
    Do you have any hint for us ?
    Best regards
    Andreas Saake
    null

    As I can see it's an error from Paging.jar.
    I do an initial call to a XSQL page with a select resultset of 38 rows, for example. With a pagesize of 20 rows I should get 2 pages and having current-page set to 1.
    But what I get is a corrected value (by Paging.jar) of current-page, which starts with page 2. The further paging in my application is ok.
    I've extended the paging handler with a variable called test-paged, which reads the paramater p and stores it in the output tree. Then I dislay the XSQL-page without any stylesheet and get a value of 38 in test-page.
    Below is an excerpt of my paging.jar:
    ---- Start excerpt
    import oracle.xml.xsql.*;
    import oracle.xml.parser.v2.*;
    import org.w3c.dom.*;
    import java.net.*;
    import java.util.StringTokenizer;
    import java.sql.SQLException;
    public class Paging extends XSQLActionHandlerImpl {
    private static final String PAGE_PARAM_NAME = "p";
    private static final String ROWSPERPAGE = "rows-per-page";
    private static final String TARGETPAGEARGS = "url-params";
    private static final String TARGETSORTARGS = "sort-params";
    public void handleAction(Node root) throws SQLException {
    XSQLPageRequest req = getPageRequest();
    Element actElt = getActionElement();
    // Get the count query from the action element content
    String query = getActionElementContent();
    // Get the number of rows per page, defaulting to 10
    long pageSize = longVal(getAttributeAllowingParam(ROWSPERPAGE,actElt),10);
    long totalRows = longVal(firstColumnOfFirstRow(root,query),0);
    long curPage = longVal(variableValue(PAGE_PARAM_NAME,actElt),1);
    long testPage = longVal(variableValue(PAGE_PARAM_NAME,actElt),1);
    // Get the name of the current page to use as the target
    String pageName = curPageName(req);
    // Get any URL parameter names that need to be echoed into paging URL's
    String pageArgs = getAttributeAllowingParam(TARGETPAGEARGS,actElt);
    // Get any URL parameter names that need to be echoed into paging URL's
    // FOR SORTING
    String sortArgs = getAttributeAllowingParam(TARGETSORTARGS,actElt);
    // Calculate the total number of pages
    long totalPages = totalRows / pageSize;
    long fract = totalRows % pageSize;
    if (fract > 0) totalPages++;
    // Make sure current page is between 1 < cur < totalPages
    if (curPage < 1) curPage = 1;if (curPage > totalPages) curPage = totalPages;
    // Create the <paging> fragment to add to the "data page"
    Document d = actElt.getOwnerDocument();
    Element e = d.createElement("paging");
    root.appendChild(e);
    addResultElement(e,"total-rows",Long.toString(totalRows));
    addResultElement(e,"total-pages",Long.toString(totalPages));
    addResultElement(e,"test-page",Long.toString(testPage));
    addResultElement(e,"current-page",Long.toString(curPage));
    --- END Excerpt
    Thanks,
    Andreas
    null

  • Paging - Rows in first page also showing in second page: listitemcollectionposition

    Hi,
    I am trying to use the listitemcollectionposition to achieve paging. The pagination is shown, but some of the records in first page are getting displayed in second page as well.
    I have totally 13 records in the list, and paging is applied for 10 items to show. I have set the rowcount to 10.
    private void FillData(string pagingInfo)
    int currentPage = Convert.ToInt32(ViewState["CurrentPage"]);
    uint rowCount = 10; // Default of 10 items per page
    string columnValue = string.Empty;
    string nextPageString = "Paged=TRUE&p_ID={0}&p_";
    string PreviousPageString = "Paged=TRUE&PagedPrev=TRUE&p_ID={0}&p_";
    SPListItemCollection collection;
    collection = GetTestItems(pagingInfo, rowCount);
    public SPListItemCollection GetTestItems(string pagingInfo, uint rowLimit)
    using (SPSite oSite = new SPSite(Sitename))
    using (SPWeb oWeb = oSite.OpenWeb())
    SPList lstPages = oWeb.Lists["Pages"];
    SPQuery sQuery = new SPQuery();
    SPListItemCollection collection;
    sQuery.RowLimit = rowLimit;
    sQuery.Query = "<Where>" +
    "<And>" +
    "<And>" +
    "<Contains><FieldRef Name='PublishingPageLayout'/><Value Type='URL'>TC_NtestPageLayout.aspx</Value></Contains>" +
    "<Eq><FieldRef Name='_ModerationStatus'/><Value Type='ModStat'>0</Value></Eq>" +
    "</And>" +
    "<Eq><FieldRef Name='_Level'/><Value Type='Integer'>1</Value></Eq>" +
    "</And>" +
    "</Where><OrderBy><FieldRef Name='TestLayoutDate' Ascending='FALSE' /></OrderBy>";
    sQuery.ViewFields = string.Concat(
    "<FieldRef Name='PublishingPageLayout' />",
    "<FieldRef Name='Title' />",
    "<FieldRef Name='EncodedAbsUrl' />",
    "<FieldRef Name='TestLayoutDate' />");
    sQuery.ViewFieldsOnly = true;
    if (!string.IsNullOrEmpty(pagingInfo))
    SPListItemCollectionPosition position = new SPListItemCollectionPosition(pagingInfo);
    sQuery.ListItemCollectionPosition = position;
    collection = lstPages.GetItems(sQuery);
    return collection;
    How to get the Paging properly?
    Thanks

    Hi,
    According to your post, my understanding is that you want to display list data using a
    SPGridView with Paging in a visual web part .
    The following code snippet for your reference:
    VisualWebPart1.ascx:
    <%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>
    <%@ Assembly Name="Microsoft.Web.CommandUI, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register TagPrefix="Utilities" Namespace="Microsoft.SharePoint.Utilities" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Register TagPrefix="asp" Namespace="System.Web.UI" Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
    <%@ Import Namespace="Microsoft.SharePoint" %>
    <%@ Register TagPrefix="WebPartPages" Namespace="Microsoft.SharePoint.WebPartPages" Assembly="Microsoft.SharePoint, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="VisualWebPart1.ascx.cs" Inherits="VisualWebPartProject3.VisualWebPart1.VisualWebPart1" %>
    <SharePoint:SPGridView ID="sgvPagersample" runat="server" AutoGenerateColumns="false" DataSourceID="objSample" AllowPaging="True" PageSize="3">
    <Columns>
    <asp:BoundField HeaderText="Title" DataField="Title" />
    <asp:BoundField HeaderText="Test1" DataField="Test1" />
    <asp:BoundField HeaderText="Test2" DataField="Test2" />
    </Columns>
    </SharePoint:SPGridView>
    <asp:ObjectDataSource ID="objSample" runat="server" SelectMethod="BindGridView"></asp:ObjectDataSource>
    <center>
    <SharePoint:SPGridViewPager id="sgvPager" runat="Server" GridViewId="sgvPagersample"></SharePoint:SPGridViewPager>
    </center>
    VisualWebPart1.ascx.cs:
    using System;
    using System.ComponentModel;
    using System.Web.UI.WebControls.WebParts;
    using System.Data;
    using Microsoft.SharePoint;
    namespace VisualWebPartProject3.VisualWebPart1
    [ToolboxItemAttribute(false)]
    public partial class VisualWebPart1 : WebPart
    // Uncomment the following SecurityPermission attribute only when doing Performance Profiling using
    // the Instrumentation method, and then remove the SecurityPermission attribute when the code is ready
    // for production. Because the SecurityPermission attribute bypasses the security check for callers of
    // your constructor, it's not recommended for production purposes.
    // [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Assert, UnmanagedCode = true)]
    public VisualWebPart1()
    protected override void OnInit(EventArgs e)
    base.OnInit(e);
    InitializeControl();
    protected void Page_Load(object sender, EventArgs e)
    objSample.TypeName = this.GetType().AssemblyQualifiedName;
    public DataTable BindGridView()
    SPWeb currentWeb = SPContext.Current.Web;
    SPList lstEmployee = currentWeb.Lists["CustomList4"];
    SPQuery sQuery = new SPQuery();
    sQuery.Query = "<OrderBy><FieldRef Name='ID' Ascending='False' /></OrderBy>";
    SPListItemCollection myColl = lstEmployee.GetItems(sQuery);
    return myColl.GetDataTable();
    Thanks,
    Dennis Guo
    TechNet Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected].
    Dennis Guo
    TechNet Community Support

  • Problem with range page with SQL Server

    Please help
    JDev version JDEVADF_11.1.1.7.0_GENERIC_130226.1400.6493
    I am using range paging for one of the VOs. The VO is based on single table. The VO is bounded to af:table. We need to support both Oracle and SQL server.
    When database is Oracle , the range paging works fine.
    But when database is SQLServer only first page is fetched properly, all the other pages are just copy of first page. The pagesize is default (25).
    Did I miss anything ?
    With accessMode=Scrollable the table show correct data for both Oracle and SQLServer.
    This is my VO XML
    <?xml version="1.0" encoding="windows-1252" ?>
    <!DOCTYPE ViewObject SYSTEM "jbo_03_01.dtd">
    <!---->
    <ViewObject
      xmlns="http://xmlns.oracle.com/bc4j"
      Name="MessagesROVO"
      Version="11.1.1.64.93"
      InheritPersonalization="true"
      OrderBy='"TIMESTAMP" desc'
      BindingStyle="JDBC"
      CustomQuery="true"
      RowClass="model.bc4j.queries.admin.MessagesROVORowImpl"
      ComponentClass="model.bc4j.queries.admin.MessagesROVOImpl"
      FetchMode="FETCH_AS_NEEDED"
      PageIterMode="Full"
      UseGlueCode="false"
      Passivate="All"
      AccessMode="RANGE_PAGING">
      <DesignTime>
        <Attr Name="_codeGenFlag2" Value="Access|Coll|VarAccess"/>
        <Attr Name="_isExpertMode" Value="true"/>
        <Attr Name="_isCodegen" Value="true"/>
      </DesignTime>
      <Properties>
        <SchemaBasedProperties>
          <LABEL
            ResId="model.bc4j.queries.admin.MessagesROVO_LABEL"/>
        </SchemaBasedProperties>
      </Properties>
      <Variable
        Name="BINDApplicationName"
        Kind="viewcriteria"
        Type="java.lang.String">
        <AttrArray Name="ExtendedDataInts">
          <Item Value="0"/>
        </AttrArray>
      </Variable>
      <Variable
        Name="BINDServerName"
        Kind="viewcriteria"
        Type="java.lang.String">
        <AttrArray Name="ExtendedDataInts">
          <Item Value="1"/>
        </AttrArray>
      </Variable>
      <Variable
        Name="BINDStartTimestamp"
        Kind="viewcriteria"
        Type="java.lang.Float">
        <AttrArray Name="ExtendedDataInts">
          <Item Value="3"/>
        </AttrArray>
      </Variable>
      <Variable
        Name="BINDEndTimestamp"
        Kind="viewcriteria"
        Type="java.lang.Float">
        <AttrArray Name="ExtendedDataInts">
          <Item Value="4"/>
        </AttrArray>
      </Variable>
      <SQLQuery>
        <![CDATA[SELECT
        ERRORLOG.SGUID GUID,
        ERRORLOG.LLOGTYPE LOGTYPE,
        ERRORLOG.DTIMESTAMP TIMESTAMP,
        ERRORLOG.SSERVERNAME SERVERNAME,
        ERRORLOG.SAPPNAME APPNAME,
        ERRORLOG.SXMLERROR XMLERROR
    FROM
        ERRORLOG ERRORLOG]]>
      </SQLQuery>
      <ViewAttribute
        Name="Guid"
        IsUpdateable="false"
        IsPersistent="false"
        IsNotNull="true"
        PrecisionRule="true"
        Precision="40"
        Scale="0"
        Type="java.lang.String"
        ColumnType="NVARCHAR2"
        AliasName="GUID"
        Expression="GUID"
        SQLType="VARCHAR">
        <DesignTime>
          <Attr Name="_DisplaySize" Value="40"/>
        </DesignTime>
      </ViewAttribute>
      <ViewAttribute
        Name="LogType"
        IsUpdateable="false"
        IsPersistent="false"
        PrecisionRule="true"
        Precision="6"
        Scale="0"
        Type="java.lang.Integer"
        ColumnType="NUMBER"
        AliasName="LOGTYPE"
        Expression="LOGTYPE"
        SQLType="INTEGER">
        <DesignTime>
          <Attr Name="_DisplaySize" Value="7"/>
        </DesignTime>
      </ViewAttribute>
      <ViewAttribute
        Name="Timestamp"
        IsUpdateable="false"
        IsPersistent="false"
        PrecisionRule="true"
        Precision="54"
        Scale="0"
        Type="java.lang.Float"
        ColumnType="FLOAT"
        AliasName="TIMESTAMP"
        Expression="TIMESTAMP"
        SQLType="FLOAT">
        <DesignTime>
          <Attr Name="_DisplaySize" Value="18"/>
        </DesignTime>
        <Dependencies>
          <Item
            Value="OccuredAt"/>
        </Dependencies>
      </ViewAttribute>
      <ViewAttribute
        Name="ServerName"
        IsUpdateable="false"
        IsPersistent="false"
        PrecisionRule="true"
        Precision="64"
        Scale="0"
        Type="java.lang.String"
        ColumnType="NVARCHAR2"
        AliasName="SERVERNAME"
        Expression="SERVERNAME"
        SQLType="VARCHAR">
        <DesignTime>
          <Attr Name="_DisplaySize" Value="64"/>
        </DesignTime>
      </ViewAttribute>
      <ViewAttribute
        Name="AppName"
        IsUpdateable="false"
        IsPersistent="false"
        PrecisionRule="true"
        Precision="10"
        Scale="0"
        Type="java.lang.String"
        ColumnType="NVARCHAR2"
        AliasName="APPNAME"
        Expression="APPNAME"
        SQLType="VARCHAR">
        <DesignTime>
          <Attr Name="_DisplaySize" Value="10"/>
        </DesignTime>
      </ViewAttribute>
      <ViewAttribute
        Name="XmlError"
        IsUpdateable="false"
        IsQueriable="false"
        IsPersistent="false"
        PrecisionRule="true"
        Type="java.lang.String"
        ColumnType="LONGVARCHAR"
        AliasName="XMLERROR"
        Expression="XMLERROR"
        SQLType="VARCHAR"/>
      <ViewAttribute
        Name="OccuredAt"
        IsUpdateable="false"
        IsSelected="false"
        IsPersistent="false"
        PrecisionRule="true"
        Type="java.sql.Date"
        ColumnType="DATE"
        AliasName="VIEW_ATTR"
        SQLType="DATE"/>
      <ViewAttribute
        Name="Summary"
        IsUpdateable="false"
        IsSelected="false"
        IsPersistent="false"
        PrecisionRule="true"
        Type="java.lang.String"
        ColumnType="VARCHAR2"
        AliasName="VIEW_ATTR"
        SQLType="VARCHAR"/>
      <ViewAttribute
        Name="TechnicalError"
        IsUpdateable="false"
        IsSelected="false"
        IsPersistent="false"
        PrecisionRule="true"
        Type="java.lang.String"
        ColumnType="VARCHAR2"
        AliasName="VIEW_ATTR"
        SQLType="VARCHAR"/>
      <ViewCriteria
        Name="MessagesROVOCriteria"
        ViewObjectName="model.bc4j.queries.admin.MessagesROVO"
        Conjunction="AND">
        <Properties>
          <CustomProperties>
            <Property
              Name="displayOperators"
              Value="InAdvancedMode"/>
            <Property
              Name="autoExecute"
              Value="false"/>
            <Property
              Name="allowConjunctionOverride"
              Value="true"/>
            <Property
              Name="showInList"
              Value="false"/>
            <Property
              Name="mode"
              Value="Basic"/>
          </CustomProperties>
        </Properties>
        <ViewCriteriaRow
          Name="vcrow6"
          UpperColumns="1">
          <ViewCriteriaItem
            Name="Timestamp"
            ViewAttribute="Timestamp"
            Operator="BETWEEN"
            Conjunction="AND"
            Required="Optional">
            <ViewCriteriaItemValue
              Name="MessagesROVOCriteria_vcrow6_Timestamp_vcval0"
              Value=":BINDStartTimestamp"
              IsBindVarValue="true"/>
            <ViewCriteriaItemValue
              Name="MessagesROVOCriteria_vcrow6_Timestamp_vcval1"
              Value=":BINDEndTimestamp"
              IsBindVarValue="true"/>
          </ViewCriteriaItem>
          <ViewCriteriaItem
            Name="ServerName"
            ViewAttribute="ServerName"
            Operator="="
            Conjunction="AND"
            Value=":BINDServerName"
            IsBindVarValue="true"
            Required="Optional"/>
          <ViewCriteriaItem
            Name="MessagesROVOCriteria_vcrow6_AppName"
            ViewAttribute="AppName"
            Operator="="
            Conjunction="AND"
            Value=":BINDApplicationName"
            IsBindVarValue="true"
            Required="Optional"/>
        </ViewCriteriaRow>
      </ViewCriteria>
      <AttrArray Name="KeyAttributes">
        <Item Value="Guid"/>
      </AttrArray>
      <ResourceBundle>
        <XliffBundle
          id="model.resource.ViewObjectsBundle_en"/>
      </ResourceBundle>
    </ViewObject>

    ADF does not support VO Range Paging with MS SQL Server. ADF supports VO Range Paging only with Oracle DB:
    Oracle ADF Business Components with Multiple Databases
    As far as the document above is not quite clear, I took a look inside the source code of the methods buildRangePagingQuery(...) of classes oracle.jbo.server.ViewObjectImpl, oracle.jbo.server.BaseSQLBuildeImpl, oracle.jbo.server.SQLServerSQLBuilderImpl and oracle.jbo.server.OracleSQLBuilderImpl (ADF 11.1.1.7) in order to confirm my statement.
    In my opinion, it is possible to add Range Paging support for a SQLServer-backed VO by implementing a custom VO class and overriding the method ViewObjectImpl.buildRangePagingQuery(...). Your method implementation should take into account the specifics of MS SQL Server and its SQL syntax.
    Dimitar
    Message was edited by: DimitarDimitrov
    P.S. The oracle.jbo.server.SQLServerSQLBuilderImpl class does not implement its own buildRangePagingQuery() method and uses the method implementation from its base class oracle.jbo.server.BaseSQLBuilderImpl, The base implementation just returns the original VO query intact. This is the reason you get the same rows as from the 1st page when you try to navigate through the pages.

  • Gallery Paging Issues

    We created a gallery using Adobe's Spry library, but the page
    between the images isn't working correctly.
    We've made similiar galleries in the past with paging, but
    with thumbnails and they worked well.
    I'm pretty sure we made a mistake with our custom JavaScript,
    but any help would be appreciated. It is based off an example from
    Adobe's Spry examples page.
    Thanks in advance for any help you can provide. The page link
    is below:
    Link:
    http://marisa.liquidcomma.com/gallery_test.html

    Hi jsuissa,
    Looking at your code, if all you are trying to do is step
    through all of the photos that are within your XML file, and you
    want to associate the portfolio name with the photos, rather than
    using a nested data set, perhaps you should just use the subPaths
    constructor argument to ds1. This would eliminate the need for all
    of that other paging code.
    To see the difference between subPaths and nested data sets,
    take a look at this sample:
    http://labs.adobe.com/technologies/spry/samples/data_region/NestedXMLDataSample.html
    What I am seeing here is basically this:
    var ds1 = new Spry.Data.XMLDataSet("gallery.xml",
    "portfolio/portfolio_item", { subPaths: [ "photos/photo" ] });
    And then you could simply show your image like this:
    <span class="gallery_slide_imgwrap"
    spry:detailregion="ds1">
    <img src="{photos/photo}" alt="{photos/photo}" />
    </span>
    And the previous/next links could call functions that look
    like this:
    function ShowPreviousPhoto()
    var prev = ds1.getCurrentRowNumber() -1;
    if (prev >= 0)
    ds1.setCurrentRowNumber(prev);
    function ShowNextPhoto()
    var next= ds1.getCurrentRowNumber() + 1;
    if (next < ds1.getRowCount())
    ds1.setCurrentRowNumber(next);
    --== Kin ==--

Maybe you are looking for