﻿<?xml version="1.0" encoding="UTF-8"?>
<!--RSS generated by Microsoft SharePoint Foundation RSS Generator on 5/23/2013 3:09:42 AM -->
<?xml-stylesheet type="text/xsl" href="/Blogs/cas/_layouts/RssXslt.aspx?List=56952d65-f588-4cdd-b1f6-7a67271cf37a" version="1.0"?>
<rss version="2.0">
  <channel>
    <title>Cas | zevenseas | SharePoint Blog: Posts</title>
    <link>http://community.zevenseas.com/Blogs/cas/Lists/Posts/AllPosts.aspx</link>
    <description>RSS feed for the Posts list.</description>
    <lastBuildDate>Thu, 23 May 2013 01:09:42 GMT</lastBuildDate>
    <generator>Microsoft SharePoint Foundation RSS Generator</generator>
    <ttl>60</ttl>
    <language>en-US</language>
    <image>
      <title>Cas | zevenseas | SharePoint Blog: Posts</title>
      <url>http://community.zevenseas.com/Blogs/cas/_layouts/images/siteIcon.png</url>
      <link>http://community.zevenseas.com/Blogs/cas/Lists/Posts/AllPosts.aspx</link>
    </image>
    <item>
      <title>Adding Lists Programmatically based on a custom ListTemplate</title>
      <link>http://community.zevenseas.com/Blogs/cas/Lists/Posts/ViewPost.aspx?ID=14</link>
      <description><![CDATA[<div><b>Body:</b> <div class="ExternalClassE20FDA55BA2D45ED81DF019494B02052"><p>When adding Lists programmatically, it's most likely we use the <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splistcollection_methods" target="_blank">Lists.Add()</a> Methods. These Methods are giving us choice on how to create the list. In my case I wanted to use a custom ListTemplate which is inside a custom Feature.     <br /></p>  <h3>Feature Activation</h3>  <p>First I chose to get my custom <a href="http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splisttemplate.aspx" target="_blank">SPListTemplate</a> from the Web and use the <a href="http://msdn.microsoft.com/en-us/library/ms477358" target="_blank">Add(String, String, SPListTemplate)</a> Method. But I figured I had to activate the Feature that has the Template in it so I can retrieve it from the SPWeb. Now I didn't want to do that because there was a whole lot of templates and declarative lists inside I didn't want to use.     <br /> </p>  <h3>Solution</h3>  <p>When I came across the last override of this Method <a href="http://msdn.microsoft.com/en-us/library/ee580457" target="_blank">Add(String, String, String, String, Int32, String, String, SPFeatureDefinition, SPListTemplate.QuickLaunchOptions)</a>. It didn't say anything about the Feature needed activation. I tried it and so it seemed. The List is Created based on the correct Template and the Feature that hosts the Template stays inactive.     <br /></p>  <h3>Example</h3>  <p>The call I now use to create my custom List is:</p>  <blockquote>   <p>Guid discListId = web.Lists.Add(“My Discussions”, &quot;Forum for community discussions&quot;, “Lists/Discussions”, &quot;feature id as string&quot;, Template ID, &quot;100&quot;);      <br /></p> </blockquote>  <h3>Summary</h3>  <p>While this is not a very common scenario, there might be some cases where you need just that ListTemplate from an installed Feature which you don’t want to activate for that Site(Collection). It’s good to know this way of adding a SPList programmatically give you the chance to do so. </p></div></div>
<div><b>Category:</b> <a onclick="OpenPopUpPage('http://community.zevenseas.com/Blogs/cas/_layouts/listform.aspx?PageType=4&ListId={AE1205DE-FB9F-4538-B07A-D3D1DF45F901}&ID=5&RootFolder=*', RefreshPage); return false;" href="http://community.zevenseas.com/Blogs/cas/_layouts/listform.aspx?PageType=4&ListId={AE1205DE-FB9F-4538-B07A-D3D1DF45F901}&ID=5&RootFolder=*">SharePoint 2010</a></div>
<div><b>Published:</b> 6/20/2012 6:53 AM</div>
]]></description>
      <author>Cas van Iersel</author>
      <category>SharePoint 2010</category>
      <pubDate>Wed, 20 Jun 2012 13:53:33 GMT</pubDate>
      <guid isPermaLink="true">http://community.zevenseas.com/Blogs/cas/Lists/Posts/ViewPost.aspx?ID=14</guid>
    </item>
  </channel>
</rss>