SharePoint 2010以编程方式列表,添加photofield

本文关键字:添加 photofield 列表 方式 2010 编程 SharePoint | 更新日期: 2023-09-27 18:18:18

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

    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允许用户上传照片的特定条目?

SharePoint 2010以编程方式列表,添加photofield

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