share point 客户端模式 创建 list

Posted Greg

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了share point 客户端模式 创建 list相关的知识,希望对你有一定的参考价值。

 /// <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 point 客户端模式 创建 list的主要内容,如果未能解决你的问题,请参考以下文章

FTP服务器的搭建

在 django 模板中过滤 object_list

如何排序 List<Point> [重复]

PowerShell Create share

无线AP(Access Point)是什么

c#如何定义全局变量list