Tuesday, 10 April 2012

Creating List Programmatically from List Defination

Referencing from http://passionatetechie.blogspot.com/2011/01/creating-list-using-list-definition.html

using (SPSite site = new SPSite(SUB_MOM_URL))
{
using (SPWeb web = site.OpenWeb())
{
web.AllowUnsafeUpdates = true;

web.Lists.Add("SubjectList", "SubjectList", "Lists/SubjectList", "4a83c786-819a-4a42-928c-15ede45a4d11", 10111, "101");
web.Update();
SPList list = web.Lists["SubjectList"];
list.OnQuickLaunch = true;
list.Update();
web.AllowUnsafeUpdates = false;

}
}



"4a83c786-819a-4a42-928c-15ede45a4d11" - Feature ID of my custom list defination

10111 - TemplateType that I have set for SubjectList when defining

No comments:

Post a Comment