zoukankan      html  css  js  c++  java
  • 复制一个list的结构

    转自jianyi的博客

    SPList EnsureArchiveList( SPList templateList)
            {
                SPWeb web = templateList.ParentWeb;
                SPList list = templateList;

                SPList archiveList = null;

                string archiveListTitle = list.Title + "(Archive)";

                try
                {
                    archiveList = web.Lists[archiveListTitle];
                }
                catch { }

                if (archiveList == null)
                {
                    web.AllowUnsafeUpdates = true;

                    string url = "Archive/" + list.RootFolder.Url;
                
                    Guid listId = web.Lists.Add(list.Title + "(Archive)", "List for archive.",  url , list.TemplateFeatureId.ToString(), (int)list.BaseTemplate, "");

                    archiveList = web.Lists[listId];

                    foreach (SPField f in list.Fields)
                    {
                        if (archiveList.Fields.ContainsField(f.InternalName) == false)
                        {
                            archiveList.Fields.Add(f);
                        }
                    }
                }

                return archiveList;       
            }

    可以用于list的备份

  • 相关阅读:
    数组的学习(一)
    Servlet是线程安全吗?
    MySql用户管理:添加用户、授权、删除用户
    泛型(二)
    泛型(一)
    Spring MVC
    spring框架
    mybatis基础
    Hibernate 基础
    Java局部类
  • 原文地址:https://www.cnblogs.com/ceci/p/1518292.html
Copyright © 2011-2022 走看看