SharePoint 2010列表以编程方式添加照片平台

时间:2013-06-12 17:47:47

标签: c# sharepoint-2010 sharepoint-list

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

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

1 个答案:

答案 0 :(得分:0)

您希望在列表中创建this type字段,并将this property设置为SPUrlFieldFormatType.Image。我从来没有使用过图片字段而且不知道上传是如何工作的,但我猜测在创建和编辑表单中会有一个上传文件控件。