Click here to Skip to main content
15,937,198 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need help to update List Item/Metadata property of a document already exist in Sharepoint Document Library using Sharepoint Object Model.
fjdiewornncalwe 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

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
Share this answer
SharepointFunda 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
[no name] 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 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 = "<where><eq><fieldref name="DocID"><value type="Text">" + strDocID + "";
qry.ViewFields = "<fieldref name="FileLeafRef"><fieldref name="Title"><fieldref name="DocID"><fieldref name="Category"><fieldref name="Approved"><fieldref name="Rejected"><fieldref name="DueDate"><fieldref name="DocumentURL"><fieldref name="ID"><fieldref name="LinkFilenameNoMenu"><fieldref name="LinkFilename">";
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)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900