标签:share param title opd exe 北京市 stat rip div
/// <summary> /// 创建新的列表 list /// </summary> /// <param name="web"></param> /// <param name="context"></param> public static void CreateLsit(Web web, ClientContext context) { //表名 string tableName = "Form11List"; ListCreationInformation listCreationInfo = new ListCreationInformation(); listCreationInfo.Title = tableName; listCreationInfo.TemplateType = (int)ListTemplateType.GenericList; List list_Info = web.Lists.Add(listCreationInfo); list_Info.Description = "New Description"; // Add fields to the list. Field field1 = list_Info.Fields.AddFieldAsXml( @"<Field Type=‘Choice‘ DisplayName=‘City‘ Format=‘Dropdown‘> <Default>北京市</Default> <CHOICES> <CHOICE>上海市</CHOICE> <CHOICE>深圳市</CHOICE> </CHOICES> </Field>", true, AddFieldOptions.DefaultValue); Field field2 = list_Info.Fields.AddFieldAsXml( @"<Field Type=‘Number‘ DisplayName=‘Name‘/>", true, AddFieldOptions.DefaultValue); Field field3 = list_Info.Fields.AddFieldAsXml( @"<Field Type=‘Number‘ DisplayName=‘Age‘/>", true, AddFieldOptions.DefaultValue); Field field4 = list_Info.Fields.AddFieldAsXml( @"<Field Type=‘Number‘ DisplayName=‘Desc‘/>", true, AddFieldOptions.DefaultValue); list_Info.Update(); context.ExecuteQuery(); List announcementsList = context.Web.Lists.GetByTitle(tableName); ListItemCreationInformation itemCreateInfo = new ListItemCreationInformation(); ListItem newItem = announcementsList.AddItem(itemCreateInfo); newItem["Title"] = "My New Item!"; newItem["Name"] = "1"; newItem["Age"] = "28"; newItem["Desc"] = "1"; newItem.Update(); context.ExecuteQuery(); }
标签:share param title opd exe 北京市 stat rip div
原文地址:http://www.cnblogs.com/foreverfendou/p/7638616.html