Skip to content

Instantly share code, notes, and snippets.

@Na0mir
Last active January 3, 2016 23:49
Show Gist options
  • Save Na0mir/8537884 to your computer and use it in GitHub Desktop.
Save Na0mir/8537884 to your computer and use it in GitHub Desktop.
Get SharePoint item (SPListItem) using CAML from column's name.
// ----------------------------------------------
// Author: Romain Blanchard
// Date: 21.01.2014
// Description: Get SharePoint item (SPListItem) using CAML from column's name.
// ----------------------------------------------
SPList Library = web.Lists[<ListName>];
SPQuery ItemQuery = new SPQuery();
ItemQuery.Query = "<Where><Eq><FieldRef Name=\"<ColumnName>\" /><Value Type='Text'>" + <Value> + "</Value></Eq></Where>";
SPListItemCollection ListItemCollection = Library.GetItems(ItemQuery);
SPListItem item = ListItemCollection[0];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment