Great. That works very nicely.
Has anyone had success with paging the results by rowlimit using 
ListItemCollectionPosition? Struggling to find decent examples that don’t use a 
data table.
The best preacgice example here - 
http://msdn.microsoft.com/en-us/library/bb687949.aspx#WorkingWithFoldersLists – 
looks straightforward enough but does not explain how to create controls to 
navigate between the row sets.
I just want something very simple that just shows a prev "<<" and next ">>" 
link. Would the following be a step in the right direction?
// Get our query items and current position
SPListItemCollection listItems = oList.GetItems(oQuery);
SPListItemCollectionPosition itemPos = listItems.ListItemCollectionPosition;
int iPos = (oQuery.RowLimit * itemPos) + 1;

foreach (SPListItem listItem in listItems)
{
    // Define previous and next links
    string nextPage ="<a onclick=\"javascript:SubmitFormPost(&quot;" + oUrl + 
"?Paged=TRUE&p_FileLeafRef=" +
        listItem["FileLeafeRef"] + "&p_ID=" + pPos + "&PageFirstRow=" + iPos +
        "&quot;);javascript:return false;\" href=\"javascript:\">&gt;&gt;</a>";

   string prevPage = ...

From: ozmoss-boun...@ozmoss.com [mailto:ozmoss-boun...@ozmoss.com] On Behalf Of 
Paul Noone
Sent: Friday, 28 October 2011 8:30 AM
To: ozMOSS
Subject: RE: Filter item collection

Thanks guys. The initial idea was to create a new library for each “album” but 
this seemed like overkill given that I added a web part to the feature.
@ishai I was planning on running it against the Name field for each item in the 
foreach loop. ☺
The query sounds a lot more efficient.
Now to add my asset picker to avoid all the issues with incorrect list names. ☺
From: ozmoss-boun...@ozmoss.com [mailto:ozmoss-boun...@ozmoss.com] On Behalf Of 
Salman Ahmad
Sent: Wednesday, 26 October 2011 5:09 PM
To: ozMOSS
Subject: Re: Filter item collection

Hi Paul,

query something like this will work for you..

<Where>
    <Contains>
    <FieldRef Name="Title" />
<Value Type="Text">YourString</Value>
    </Contains>
</Where>

Additionally, You can also search multiple string in same query using <In>, if 
you have exact strings. [cid:image001.png@01CC955C.BF509180]

   <Where>
        <In>
  <FieldRef Name='Title' />
  <Values>
     <Value Type = 'Text'>String1</Value>
     <Value Type = 'Text'>String2</Value>
     <Value Type = 'Text'>String3</Value>
 </Values>
      </In>
</Where>

Cheers,


From: Ishai Sagi<mailto:is...@exd.com.au>
Sent: Wednesday, October 26, 2011 4:09 AM
To: ozMOSS<mailto:ozmoss@ozmoss.com>
Subject: RE: Filter item collection

Startswith is something you do on a string, not on a collection. To properly 
(and efficiently) get items with a certain criteria from a list, you should do 
a query on the list.
The query can then have a “BeginsWith” or “Contains” filter parameter (see 
http://msdn.microsoft.com/en-us/library/ms467521.aspx for all parameters you 
can specify) so you can get a collection of only the items that answer the 
filter criteria.


[cid:image003.jpg@01CC955C.BF509180]Ishai Sagi | Solutions Architect
0488 789 786 | is...@exd.com.au<mailto:is...@exd.com.au> | 
www.sharepoint-tips.com<http://www.sharepoint-tips.com/> | 
@ishaisagi<http://twitter.com/ishaisagi>

From: ozmoss-boun...@ozmoss.com [mailto:ozmoss-boun...@ozmoss.com] On Behalf Of 
Paul Noone
Sent: Wednesday, 26 October 2011 10:57 AM
To: ozMOSS (ozmoss@ozmoss.com)
Subject: Filter item collection

Hi all,
I want to filter an SPListItemCollection based on a provided string in the item 
Name.
Can I do this using string StartsWith, or should I run an SPQuery against the 
collection?
Kind regards,

Paul Noone

---------------------------------------------------
Online Developer/SharePoint Administrator
Infrastructure Team, ICT
Catholic Education Office, Sydney
p: (02) 9568 8461
f: (02) 9568 8483
e: paul.no...@ceosyd.catholic.edu.au<mailto:paul.no...@ceosyd.catholic.edu.au>
w: http://www.ceosyd.catholic.edu.au/

________________________________
_______________________________________________
ozmoss mailing list
ozmoss@ozmoss.com<mailto:ozmoss@ozmoss.com>
http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss

<<inline: image001.png>>

<<inline: image003.jpg>>

_______________________________________________
ozmoss mailing list
ozmoss@ozmoss.com
http://prdlxvm0001.codify.net/mailman/listinfo/ozmoss

Reply via email to