如何在文档库中设置查找字段?(sharepoint 2010)

时间:2010-08-04 06:41:02

标签: c# sharepoint-2010

我有一个名为DropOffLibrary的文档库。此外,我在此库中有一个查找列ElDocsBatch。所以我需要设置一个特定的值

SPFieldLookupValue newValue = new SPFieldLookupValue(11,"Account");

用于此查找字段。

1 个答案:

答案 0 :(得分:0)

最后我解决了我的问题。=))

SPListCollection collLists = oWeb.Lists; //Get All lists
foreach (SPList oList in collLists)
{
   if (oList.BaseType == SPBaseType.DocumentLibrary) //Serach for all Libraries
   {
      SPDocumentLibrary oDocumentLibrary = (SPDocumentLibrary)oList;
      string name = oDocumentLibrary.Title.ToString();

      if (name == "LibraryName") //Get library what you need
      {
         SPListItem row = oDocumentLibrary.Items[i]; //get an element by id in library
         SPFieldLookupValue newValue = new SPFieldLookupValue( id , "LookupFieldValue");
         row["field_name"] = newValue;