Вопрос

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?

Это было полезно?

Решение

You want to create a field of this type in your list, setting this property to 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 с атрибуция
Не связан с StackOverflow
scroll top