I would like to create a menu from the listtemplate Promoted Links, with several tiles. I use the following code to create the list, and create new list items:
ListTemplate listTemplate = web.ListTemplates.GetByName("Promoted Links");
context.Load(listTemplate);
// Execute the query to the server
context.ExecuteQuery();
// Create a new object for ListCreationInformation class - used to specify the properties of the new list
ListCreationInformation creationInfo = new ListCreationInformation();
// TITEL
creationInfo.Title = "KlasseSite menu";
// description
creationInfo.Description = "Tile menu";
creationInfo.TemplateFeatureId = listTemplate.FeatureId;
creationInfo.TemplateType = listTemplate.ListTemplateTypeKind;
web.Lists.Add(creationInfo);
context.ExecuteQuery();
// new list item
List announcementsList = context.Web.Lists.GetByTitle("KlasseSite menu");
ListItemCreationInformation itemCreateInfo = new ListItemCreationInformation();
ListItem newItem = announcementsList.AddItem(itemCreateInfo);
newItem["Title"] = "SkoleSite"; newItem["LinkLocation"] = "/sites/Engelsk";
newItem["Title"] = "Settings"; newItem["LinkLocation"] = "/sites/Engelsk/Shared%20Documents/Forms/AllItems.aspx";
newItem.Update();
context.ExecuteQuery();
My problem: This code only creates one tile, because
newItem["Title"] = "Settings"; newItem["LinkLocation"] = "/sites/Engelsk/Shared%20Documents/Forms/AllItems.aspx";
Overwrites:
newItem["Title"] = "SkoleSite"; newItem["LinkLocation"] = "/sites/Engelsk";
How can i add to several rows in the list?