Sahil
Sahil

Reputation: 63

Get List Item by GUID

I am working on sharepoint-2010 and I am new to sharepoint. I want to access List Item by Guid. So, how can I access. Please provide some reference or some class file to access that.

Thanks in advance.

Upvotes: 4

Views: 4703

Answers (1)

Marek Grzenkowicz
Marek Grzenkowicz

Reputation: 17343

Use the SPList.GetItemByUniqueId method:

using (SPSite site = new SPSite(url))
{
    using (SPWeb web = site.OpenWeb())
    {
        SPList list = web.Lists[listTitle];
        SPListItem item = list.GetItemByUniqueId(itemGuid);
    }
}

Upvotes: 2

Related Questions