I am attempting to create two lists that are linked to each other, programmatically, on activation of my web part.
public override void FeatureActivated(SPFeatureReceiverProperties properties)
{
SPWeb spWeb = properties.Feature.Parent as SPWeb;
if (spWeb != null)
{
// Create our Lists
spWeb.Lists.Add("Memeber Records", "Holds a list of Memebers", SPListTemplateType.GenericList);
spWeb.Lists.Add("Certification", "Certifications and Their Descriptions", SPListTemplateType.GenericList);
SPList list = spWeb.Lists["Memeber Records"];
SPList certList = spWeb.Lists["Certification"];
// Add Outr Fields
list.Fields.Add("Memebr ID", SPFieldType.Integer, true);
list.Fields.Add("Memeber Name", SPFieldType.Text, true);
// were missing a item - a drop down with static content such as: Association, Company, Head Office
list.Fields.Add("Memeber Certification", SPFieldType.Lookup, false);
list.Update();
certList.Fields.Add("Certfication Title", SPFieldType.Text, true);
certList.Fields.Add("Description", SPFieldType.Text, true); // This one should be a text box allowing 256 characters
certList.Update();
}
}
As you can see I am needing your help to figure out how to create a couple more things:
.Fields.Add()
doesn't have a drop down feature in list
certList
's second field is suppose to be a text box with up to 250 characte's if not more.certList
to list
such that when selecting a member certification it pulls from the certtList
Is there anything else that I am missing to have this work upon activation of this web part? I scoped it to site but when deploying (when I created the project, I selected) its Farm instead of Sandbox
Have you tried using the choice field. The list.Fields.Add has a overload where you can populate the choices too. I haven't tried it but this is specifically for choice fields.