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.
SharePoint 2010 Lists Programmatically, adding a photofield
-
31-05-2022 - |
Вопрос
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?
Решение
Не связан с StackOverflow