0

我有一个这样创建的列表:

    private void CreateMemberList(SPWeb web, SPList list, SPView view, StringCollection departmentSelection)
    {
        // Add Outr Fields
        list.Fields.Add("MemberID", SPFieldType.Integer, true);
        list.Fields.Add("MemberName", SPFieldType.Text, true);
        list.Fields.Add("Department", SPFieldType.Choice, true, false, departmentSelection);

        // Set the default value and the format of the choice.
        SPFieldChoice fieldChoice = (SPFieldChoice)list.Fields["Department"];
        fieldChoice.DefaultValue = "Select One";
        fieldChoice.EditFormat = SPChoiceFormatType.Dropdown;

        //Add the Lookup field
        SPList targetList = web.Lists["Certification"];
        list.Fields.AddLookup("MemberCertifications", targetList.ID, false);

        SPFieldLookup lookup = (SPFieldLookup)list.Fields["MemberCertifications"];
        lookup.LookupField = targetList.Fields["CertificationTitle"].InternalName;
        lookup.AllowMultipleValues = true;
        lookup.Update();

        list.Update();

        //Add Member View
        view.ViewFields.Add("MemberID");
        view.ViewFields.Add("MemberName");
        view.ViewFields.Add("Department");
        view.ViewFields.Add("MemberCertifications");

        //Update Views
        view.Update();
    }

此函数在激活时调用。有没有办法list.Fields.add - photofield让用户上传特定条目的照片?

4

1 回答 1

0

您想在列表中创建此类型的字段,将此属性设置为SPUrlFieldFormatType.Image。我从来没有使用过图片字段,也不知道上传是如何工作的,但我猜在创建和编辑表单中会有一个上传文件控件。

于 2013-06-12T17:57:36.590 回答