简体   繁体   English

SharePoint 2010以编程方式列出,并添加了一个照片字段

[英]SharePoint 2010 Lists Programmatically, adding a photofield

I have a list that is created as such: 我有这样创建的列表:

    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();
    }

This function is called in activation. 该功能在激活时被调用。 Is there a way I can do something list.Fields.add - photofield to allow a user to upload a photo for the specific entry? 有什么办法可以做list.Fields.add - photofield ,允许用户上传特定条目的照片?

You want to create a field of this type in your list, setting this property to SPUrlFieldFormatType.Image . 您想要在列表中创建此类型的字段, 并将 此属性设置为SPUrlFieldFormatType.Image I have never had to use a picture field and don't know how the upload would work, but I'm guessing there will be an upload file control in the creation and edition forms. 我从来没有使用过图片字段,也不知道上载的工作方式,但是我猜测在创建和编辑表单中将有一个上载文件控件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM