Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Sharepoint
Hi
 
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 16:20pm
Comments
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
good
Please Sign up or sign in to vote.

Solution 1

SPListItem item = list.Items[itemId];
item["SomeField"] = "Some value";
item.Update();
 
You'll have to be more specific in your question if you want more of an answer
  Permalink  
Comments
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"]);
_web.AllowUnsafeUpdates=true;
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;
_item.Update();
}

}

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 495
1 OriginalGriff 339
2 ChintanShukla 305
3 Richard Deeming 260
4 RyanDev 230
0 Sergey Alexandrovich Kryukov 8,768
1 OriginalGriff 7,387
2 CPallini 2,603
3 Richard MacCutchan 2,095
4 Abhinav S 1,893


Advertise | Privacy | Mobile
Web01 | 2.8.140827.1 | Last Updated 4 Jan 2011
Copyright © CodeProject, 1999-2014
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