mardi 30 décembre 2014

Cannot add item to a list



I can create a list and add a custom column to it but there are no items present in the list. Below is the code snippet.



Guid listId = web.Lists.Add("TestList", "TestList", SPListTemplateType.GenericList);
SPList list = web.Lists[listId];
list.OnQuickLaunch = false;
list.Fields.Add("Enabled", SPFieldType.Boolean, true);
list.Update();

SPListItem item = list.AddItem();
item["Title"] = "ABC";
item["Enabled"] = true;
list.Update();

item = list.AddItem();
item["Title"] = "DEF";
item["Enabled"] = true;
list.Update();







0 commentaires:

Enregistrer un commentaire