The following code snippet can be used to create a list in sharepoint site. The following example I have illustrated only DocumentLibrary creation.
public static bool CreateSPList(SPWeb web, string listName, SPListTemplateType type)
{
bool create = false;
try
{
if (type == SPListTemplateType.DocumentLibrary)
{
web.Lists.Add(listName, listName, SPListTemplateType.DocumentLibrary);
return true;
}
}
catch (Exception ex)
{
return false;
}
return create;
}
No comments:
Post a Comment