Quantcast
Channel: SharePoint 2010 - Development and Programming forum
Viewing all articles
Browse latest Browse all 11571

Where is my list template

$
0
0

I created a simple survey and saved it as a list template (no content).
I can see this list template in my subsite when I go to create a new list.

Now I am creating an event receiver that will create a new list (based on this template) when a new item is added to a different list.

public override void ItemAdding(SPItemEventProperties properties)
        {
            base.ItemAdding(properties);
            string theCourseName = properties.ListItem.Title;

            using (SPSite site = new SPSite(properties.WebUrl))
            {
                using (SPWeb web = site.OpenWeb())
                {
                    SPListTemplate theTemplate = web.ListTemplates["CourseFeedback"];
                    web.Lists.Add(theCourseName + ", Feedback", "Feedback from the course you attended", theTemplate);
                }
            }
        }

When I add a new list item nothing happens - no new list.
I look in the ULS logs and I see this error:

Error loading and running event receiver xxx.TrainingUtils.CreateCourseSurvey.CreateCourseSurvey in xxx.TrainingUtils, Version=1.0.0.0, Culture=neutral, PublicKeyToken=aba8d75e838807fc. Additional information is below.  : Object reference not set to an instance of an object.

So I open Sharepoint Manager and look at the list templates for my subsite and the parent site and do not see it listed.
I run a (home made) powershell function that lists all list templates at a given URL and again it is not there.

Am I using the wrong code (web.lists.add) for a custom template or could there be a diffeerent issue?


Viewing all articles
Browse latest Browse all 11571

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>