views:

488

answers:

2

Hi,

I have a SPList object and use SPList.Items to get the SPListItemCollection. From this collection I need to access one SPListItem for which the UniqueID or GUID is not know. Is it possible to access the element directly using Display Name or any other information (other than GUID or UniqueId). Any idea will be appreciated.

+3  A: 

Not out of the box - see the question How to access List Items in a list for the options. Retrieving the information with SPQuery is recommended to avoid placing too much load on the database. There is more information on how to use that in my answer to SharePoint : Check if item exists in a list, minimum overhead:

A good alternative is to use LINQ. This option has been provided by the community (Keith Dahlby and Wictor Wilén) and is available in the SharePoint Extensions Lib.

Alex Angas
Hi, I use this query to find the items on the basis of DisplayName. "<Where><Eq><FieldRef Name = 'DisplayName'/><Value Type='Text'>documenting</Value></Eq></Where>";But it throws an error stating that 'one or more fields are not properly installed. Is it possible to find items based on their DisplayName.
Prabhu
http://www.sharepoint-tips.com/2007/04/one-of-more-field-types-are-not.htmlMaybe You should try changing DisplayName to Title ?
Janis Veinbergs
Janis is right - you should be using <FieldRef Name='Title'/>
Alex Angas
A: 

If you are going to use CAML then the CAML Query Builder is really helpful. Personally I don't like doing CAML using a plain old string so I've been using CAML.NET to wrap CAML queries

armannvg