2011-11-07 200 views
1

我的任務有多個relateddocId,例如RelatedDoc =「3,5,2,6」,現在我需要添加multiplevalue到名爲related的sharepoint查找字段在任務列表中的文檔。如何添加這個?如何在sharepoint List中添加多個lookup值。在sharepoint中添加項目時

對於裁判見下文

private static void CreateItem(SPWeb web, SPList TaskList, string FolderURL, string ItemName, string RelatedDoc) 
    { 
     var ParentURL = string.Empty; 
     if (!TaskList.ParentWebUrl.Equals("/")) 
     { 
      ParentURL = TaskList.ParentWebUrl; 
     } 
     SPListItem _taskList = TaskList.AddItem(ParentURL + FolderURL, SPFileSystemObjectType.File, null); 
     _taskList["Title"] = ItemName; 
     string DocName = "4,6,3,6";//Document ref id. 
     SPFieldLookupValue lookupvalue = new SPFieldLookupValue(); 

     if (DocName != "") 
      lookupvalue = new SPFieldLookupValue(RelatedDoc, DocName); 
     _taskList["EYRelatedSharedDocument"] = lookupvalue; 
     _taskList.Update(); 

    } 

回答

2
SPFieldLookupValueCollection documents = new SPFieldLookupValueCollection(); 

foreach (...) 
{ 
    documents.Add(new SPFieldLookupValue(documentId, documentTitle)); 
} 

_taskList["EYRelatedSharedDocument"] = documents; 
_taskList.Update(); 
我的代碼
相關問題