Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Getlistitems and ListItemCollectionPositionNext for paging

416 views
Skip to first unread message

TS

unread,
Apr 2, 2004, 4:13:21 PM4/2/04
to
I cannot find anything that give me an example of how to implement server
side paging, all there is is the getListItems method desc. on msdn.

How do I do it?


Wei-Dong XU [MSFT]

unread,
Apr 5, 2004, 5:10:11 AM4/5/04
to
Hi TS,

From your description, you are going to set the paging for list. Is that right?

If so, there will be no need for you to develop your own paging. Sharepoing has built-in support for the list paging. For example, in the "Shared
Documents" document library page, please select the "Modify settings and columns" link from the page left area. Then click "All Documents" of Views
section. In the "Edit View" page, please click "Item Limit" to extend it, then in the text box "Number of items to display:", input the number you
specify for one page. Ok to return. You will see the document library paging is displayed at the bottom right. However, this default paging with out
one previous for you. You have to use "back" button of IE to go back in the paging. For this issuce, you can open the page in Frontpage and then
convert the web part to XSLT, then save the page. The previous button will appear for you.

If my understanding doesn't locate your question, please feel free to let me know.

Best Regards,
Wei-Dong Xu
Microsoft Product Support Services
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

TS

unread,
Apr 5, 2004, 10:36:33 AM4/5/04
to
This is the scenario. I have a custom app that I am retrieving list data
from sharepoint. I would like it to send me only the data I need for
displaying on a single page, so that it is more efficient.

This custom app piece will eventually be converted to a web part and
installed into the sharepoint site. Do I need to worry about retrieving only
a certain subset of page data so that it will work how I want, or since it
will be a web part, do I need to plan for that paging, or will sharepoint do
it automatically (I doubt).

If that wasn't clear, let me know
thanks

"Wei-Dong XU [MSFT]" <v-w...@online.microsoft.com> wrote in message
news:MdFSQ3uG...@cpmsftngxa06.phx.gbl...

Wei-Dong XU [MSFT]

unread,
Apr 6, 2004, 9:52:59 AM4/6/04
to
Hi TS,

From my view, you can convert your custom code, which retrieves the specified list items, into one web part directly. The retrieved list items are
controlled by your code. If you got any odd issue, please feel free to let me know.

TS

unread,
Apr 6, 2004, 11:14:00 AM4/6/04
to
Ok, so that means I'm going to want to use the
ListItemCollectionPositionNext. Can you tell me how to use this or point me
to somewhere that describes it. As I have noted, the single msdn doc that
describes it doesn't go into detail.

thanks

"Wei-Dong XU [MSFT]" <v-w...@online.microsoft.com> wrote in message

news:wChp659G...@cpmsftngxa06.phx.gbl...

Wei-Dong XU [MSFT]

unread,
Apr 7, 2004, 5:32:28 AM4/7/04
to
Hi TS,

For retrieving the paging items, the recommended method is to us SPQuery Class. For example, for the document library, you can use the sample
code below to retrieve the paging.
//--------
SPWeb site = SPControl.GetContextWeb(Context);
SPList list = site.Lists["Announcements"];

SPQuery query = new SPQuery();
//define the
query.RowLimit = 10;
int i = 1;

do
{
Response.Write("<BR>Page: " + i + "<BR>");
SPListItemCollection listItems = list.GetItems(query);

foreach(SPListItem listItem in listItems)
{
Response.Write(SPEncode.HtmlEncode(listItem["Title"].ToString()) + "<BR>");
}

query.ListItemCollectionPosition = listItems.ListItemCollectionPosition;
i++;
} while (query.ListItemCollectionPosition != null);
//--------

You can find more information for this from the link:
SPListItemCollectionPosition Class
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/spptsdk/html/tscSPListItemCollectionPosition.asp

Based on my research, LIstItemCollectionPositionNext is the attribute of Paging element which is encapsulated in the query. Please use SPQuery to
perform the retrieving. In the article "GetListItems Method" of SPS sdk, it gives one description for this attribute for you, which is no need for us
to set this attribute directly with code.

Please feel free to let me know if you have any further questions.

TS

unread,
Apr 7, 2004, 10:49:36 AM4/7/04
to
sounds good, thanks

"Wei-Dong XU [MSFT]" <v-w...@online.microsoft.com> wrote in message

news:oA3zGNIH...@cpmsftngxa06.phx.gbl...

TS

unread,
Apr 7, 2004, 12:20:45 PM4/7/04
to
Can you explain the diff. between these 2 and why to use one versus the
other:

I have been using a web service call where I would call GetListItems method
of my Lists class of my web reference to retrieve data into an xmlNode
object.

Using the sharepoint class to gain access to list data. Is this way a web
service call?

"Wei-Dong XU [MSFT]" <v-w...@online.microsoft.com> wrote in message

news:oA3zGNIH...@cpmsftngxa06.phx.gbl...

TS

unread,
Apr 7, 2004, 12:54:40 PM4/7/04
to
Do I have to be developing on windows 2003? How do I get the sharepoint
assembly to import into code?

"Wei-Dong XU [MSFT]" <v-w...@online.microsoft.com> wrote in message

news:oA3zGNIH...@cpmsftngxa06.phx.gbl...

TS

unread,
Apr 7, 2004, 1:41:02 PM4/7/04
to
If my custom app is not yet a web part, should I still use your
recommendation?

"Wei-Dong XU [MSFT]" <v-w...@online.microsoft.com> wrote in message

news:oA3zGNIH...@cpmsftngxa06.phx.gbl...

Wei-Dong XU [MSFT]

unread,
Apr 8, 2004, 12:42:10 PM4/8/04
to
Hi TS,

For the development of SPS, since SPS can only be supported in Windows 2003, you will need to perform the development in Windows 2003 as well.

"Can you explain the diff. between these 2 and why to use one versus the other"

This choice is up to you. If you scenario needs to consuming the SPS info from distributed location, Web service is one better choice. If you create
your web part and aspx page for running in the server-side, please use SPQuery Class which will provide better performance. My reply assumes you
are in the later scenario, for this is common. :-)

"How do I get the sharepoint assembly to import into code?"

My understanding to this question is: you want to know how to reference the sharepoint assembly. My answer: directly reference them in VS.net.

"If my custom app is not yet a web part, should I still use your recommendation?"

Of course.

TS

unread,
Apr 12, 2004, 1:13:17 PM4/12/04
to
> For the development of SPS, since SPS can only be supported in Windows
2003, you will need to perform the development in Windows 2003 as well.
I won't be able to develop on a diff. box, so I'm going to have to do do it
the web service way using ListItemCollectionPositionNext
So going back to my original post, can you tell me how to use this property
while calling GetListItems method, or point me to somewhere that describes

it. As I have noted, the single msdn doc that describes it doesn't go into
detail.

thank you

"Wei-Dong XU [MSFT]" <v-w...@online.microsoft.com> wrote in message

news:jd7rzhYH...@cpmsftngxa06.phx.gbl...

Peter Huang

unread,
Apr 13, 2004, 4:40:19 AM4/13/04
to
Hi TS,

As I know, the ListItemCollectionPositionNext has been encapsulated into
SOAP layer fo SPS. Since there is no any public documentation introducing
more info concerning this property, please use the SPQuery method from
Wei-Dong to retrieve the list items.

Kindly Regards,
Peter Huang
Microsoft Online Partner Support

TS

unread,
Apr 15, 2004, 2:19:14 PM4/15/04
to
ok

""Peter Huang"" <v-ph...@online.microsoft.com> wrote in message
news:yKnJ3LTI...@cpmsftngxa10.phx.gbl...

dining-room

unread,
Apr 1, 2011, 10:05:47 AM4/1/11
to
The XmlNode that is returned from GetListItems has a pointer to the next page
ONLY. You can use this pointer to create the QueryOptions XmlNode to get the
next page. However, there is no way to navigate to the previous page or to a
specific page.

At one point we were using GetList and GetListItems to create and pupulate an
ADO.Net DataTable with the entire List. Once we have the DataTable, we bind it
to a GridView control on and ASP.Net web page. We gave the client the ability
to
Filter, Sort and Update the data. This is a much nicer interface than anything
SharePoint has.

However, when the List became too large, GetListItems would throw the Soap
"System.OutOfMemoryException".

We had one of our subs build us a C# Class Library that is basically a wrapper
around GetList, GetListItems and UpdateListItems.

This Wrapper works in the following manner: When the class is instantiated,
the
ListURL, ListName, RowsPerPage, Query and ViewFields need to be set. GetSPList
will return the first page as an Ado.Net DataTable. It also has the PageNext,
PagePrevious and GotoPage(X) methods that return an Ado.Net DataTable. Other
read only properties include CurrentPage and TotalPages.

If ViewFields, Query or RowsPerPage are reset, it will recalculate TotalPages.
GetListItems is another read only property that holds the GetListItems
XmlNode.
This has worked perfectly for us and solved our problems.

They told us this assembly was written in C# and was unit tested using WSS
3.0,
MOSS 2007, IE 8.0 and Windows Server 2003 32bit.

We purchased only the Assembly. Not the code. If you want, I can put you in
touch with these people.
0 new messages