如何在sharepoint List中添加多个lookup值。在sharepoint中添加项目时
问题描述:
我的任务有多个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();
}
答
SPFieldLookupValueCollection documents = new SPFieldLookupValueCollection();
foreach (...)
{
documents.Add(new SPFieldLookupValue(documentId, documentTitle));
}
_taskList["EYRelatedSharedDocument"] = documents;
_taskList.Update();
我的代码