Ömer Çelik

Yazılımcının Günlüğü

Liste şablonu ile liste oluşturmak

       public static void CreateList(string strSiteURL, string ListTemplateName, string Listname)

        {

 

            SPSecurity.RunWithElevatedPrivileges(delegate

                 {

                     using (SPSite site = new SPSite(strSiteURL))

                     {

                         SPWeb web = site.OpenWeb();

                         web.AllowUnsafeUpdates = true;

                         SPListTemplateCollection listTemplates = site.GetCustomListTemplates(web);

                         SPListTemplate listTemplate = listTemplates[ListTemplateName];

                         Guid listId = web.Lists.Add(Listname, Listname, listTemplate);

                         SPList list = web.Lists[listId];

                         list.OnQuickLaunch = true;

                         list.Update();

                         web.AllowUnsafeUpdates = false;

                         site.Dispose();

                         web.Dispose();

                     }

                 });

        }

Loading