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. 

   <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 
Sent: Wednesday, October 26, 2011 4:09 AM
To: ozMOSS 
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.

 

 

Ishai Sagi | Solutions Architect 
0488 789 786 | is...@exd.com.au | www.sharepoint-tips.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
w: http://www.ceosyd.catholic.edu.au/

 



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

<<wlEmoticon-smile[1].png>>

<<image002.jpg>>

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

Reply via email to