TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Get SharePoint list item by List Unique Field using CAML Query
Ramakrishna Basagalla
Nov 20
2015
Code
5.6
k
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
// Function to get value
public
SPListItem GetRKListItemByRefNo(SPWeb objSPWeb,
string
refNo)
{
SPList objSPInvoiceList = objSPWeb.Lists[
"RKList"
];
string
camlQuery =
string
.Empty;
if
(!String.IsNullOrEmpty(refNo))
{
camlQuery =
"<View><Query><Where><Eq><FieldRef Name='RefNo' /><Value Type='Text'>"
+ refNo +
"</Value></Eq></Where></Query></View>"
;
}
SPQuery qryInv =
new
SPQuery();
qryInv.ViewXml = camlQuery;
SPListItemCollection incAnaCol = objSPInvoiceList.GetItems(qryInv);
return
incAnaCol[0];
}
// Calling the function
SPListItem item = GetRKListItemByRefNo(web, itemRefNo);
SharePoint
CAML Query
SharePoint list item by list unique