zoukankan      html  css  js  c++  java
  • 如何生成自定义列表

    添加一个列表可通过调用SPListCollection.Add方法来完成。该方法提供了如下三种形式:

        ·      Addstring title, string description, SPListTemplate template

     

    ·      Addstring title, string description, SPListTemplateType type

     

    ·      Addstring title, string description, SPListTemplate template, SPDocTemplate docTemplate

    详细文章主要链接:http://book.csdn.net/bookfiles/160/1001606878.shtml

     

    示例1主要是获取网站默认拥有的基本类型列表模版(如:通知、文档、自定义列表等)进行创建

    示例2主要是获取用户自定义的列表模版进行创建

     

    示例1  在该示例中创建一个联系人列表,并显示该列表添加条目页面的url

    // 首先获取到SPWeb对象web

    SPListCollection lists = web.Lists;

    SPList newList = null;

    try

    {

        Guid id = lists.Add("DemoList", "这是一个测试列表",

                                SPListTemplateType.Contacts);

        newList = lists[id];

        SPForm form = newList.Forms[PAGETYPE.PAGE_NEWFORM];

        Console.WriteLine(form.Url);

    }

    catch

    {

        Console.WriteLine("列表添加失败");

    }

     

     

     

    【示例2  使用网站自定义的列表模版“通讯录明细模版”,创建一个于列表模版相同的列表 

    // 首先获取到SPWeb对象web
                    SPListTemplateCollection listTemplates = site.GetCustomListTemplates(web);
                    SPListTemplate temp = null;
                    foreach (SPListTemplate temp1 in listTemplates)
                    {

                        //找到自定义模版
                        if (temp1.Name.Contains("通讯录明细模版"))
                        {
                            temp = temp1;
                        }
                    }
                    SPListCollection lists = web.Lists;
                    SPList newList = null;
                    lists.Add("DemoList1", "这是第二个测试列表", temp);
                               

  • 相关阅读:
    [Leetcode 11] 112 Path Sum
    [Leetcode 14] 7 Reverse Integer
    [Leetcode 12] 126 Word Ladder II TO_BE_ADDED
    [Leetcode 13] 1 Two Sum
    [Leetcode 7] 101 Symmetric Tree
    [Leetcode 9] 110 Balanced Binary Tree
    [Leetcode 15] 8 String to Integer (atoi)
    [Leetcode 8] 104 Maximum Depth of Binary Tree
    [Leetcode 16] 9 Palindrome Number
    [Leetcode 10] 111 Minimum Depth of Binary Tree
  • 原文地址:https://www.cnblogs.com/Anlycp/p/1278441.html
Copyright © 2011-2022 走看看