Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I want to Create List Definition & List Instance under particular Sub-site.It can not been seen under site Collection.

share|improve this question
add comment

2 Answers 2

Create your List Definition using a Web Scoped feature. Set the feature attributes to Hidden=True.

You can then activate your feature manually using PowerShell for that sub-site.

For further automation you can either staple your feature to specific templates (so it is automatically included in sites which uses a specific template) or reference it in the WebFeatures element in the Onet.xml of your custom site definition.

share|improve this answer
add comment
up vote 1 down vote accepted

Accomplished with the following code in Feature Activated event receiver.

SPSite site = null;
SPWeb web = null;
site = properties.Feature.Parent as SPSite;
web = site.AllWebs["SubSite"];
SPListTemplate temp = web.ListTemplates["ListDefinition"];
Guid newg = web.Lists.Add("ListInstance", "Description", temp);
SPList newlist = web.Lists[newg];
newlist.OnQuickLaunch = true;
newlist.Update();  
share|improve this answer
    
This will make List Named listInstance on Custom ListDefinition named listDefinition. –  Harsh Bhavsar Jun 12 '13 at 9:04
    
Thanks Robert.. –  Harsh Bhavsar Jun 12 '13 at 9:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.