Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

In my visual webpart, I want to get an item by it's id from a document library, and change it's field value. I don't want to actually read any of its field values, so I was wondering is there is a way to get an item by its id, and use a viewfields caml query to say, get this item without any fields.

Is this possible?

Thanks.

share|improve this question

3 Answers 3

up vote 2 down vote accepted

You can use the method GetItemByIdSelectedFields,

This method allows you to send as parameters the fields you want to receive

share|improve this answer

I don't think so. You better write a proper CAML query and specify the ID field on the Where clause.

share|improve this answer

What's wrong with the in-built SPList method for fetching the item by it's unique ID?

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splist.getitembyid.aspx

If it loads the default SPListItem fields it shouldn't be a concern so long as you are accessing a single item.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.