Click here to Skip to main content
11,437,978 members (51,897 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: C# Sharepoint

I need help to update List Item/Metadata property of a document already exist in Sharepoint Document Library using Sharepoint Object Model.
Posted 3-Jan-11 17:20pm
Marcus Kramer at 3-Jan-11 22:26pm
You'll need to give us a little more to go on for this. I'm not sure if your question is clear enough.

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

SPListItem item = list.Items[itemId];
item["SomeField"] = "Some value";

You'll have to be more specific in your question if you want more of an answer
SharepointFunda at 4-Jan-11 22:29pm
Thanks Mark Nischalke..

I followed your instructions and getting below error.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.

Source Error:

Line 64: {
Line 65: //SPDocumentLibrary docs = (SPDocumentLibrary)_web.Lists["DMSLibrary"];
Line 66: SPListItem _item = _web.Lists["DMSLibrary"].Items[33];
Line 67: _item["Approved"] = true;
Line 68: _item.Update();

Deepak Singh
Mark Nischalke at 4-Jan-11 22:59pm
OK. Have you debugged this code? Does the list "DMLibrary" exist? Does it have at least 32 items in it? Does the list have a field called "Approved"?

You have to make some effort on your part or contact me for my rates to help with this project.
SharepointFunda at 4-Jan-11 23:15pm
Thanks again Mar..

all the fields/ ID and document library exists.

I have done this form below code.

Please check and confirm if there is any error. It is working fine now.

SPListItemCollection _itemCol;
SPQuery qry = new SPQuery(_web.Lists["DMSLibrary"].DefaultView);
qry.Query = "" + strDocID + "";
qry.ViewFields = "";
qry.ViewAttributes = "Scope=\"RecursiveAll\"";
_itemCol = _web.Lists["DMSLibrary"].GetItems(qry);
//DataTable dtMetaData = ExecuteQuery(_web.Lists["DMSLibrary"]);
//int _docID = Convert.ToInt32(dtMetaData.DefaultView.ToTable().Rows[0]["ID"]);
if (_itemCol.Count > 0)
for (int iCount = 0; iCount < _itemCol.Count; iCount++)
//SPDocumentLibrary docs = (SPDocumentLibrary)_web.Lists["DMSLibrary"];
SPListItem _item = _itemCol[iCount];
_item["Approved"] = true;


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Advertise | Privacy | Mobile
Web01 | 2.8.150506.1 | Last Updated 4 Jan 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100