Sharepoint 内置了几种列表类型:
public enum SPBaseType
{
UnspecifiedBaseType = -1,
GenericList = 0,
DocumentLibrary = 1,
Unused = 2,
DiscussionBoard = 3,
Survey = 4,
Issue = 5,
}
/// <summary>
/// 新建列表
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btn_Click(object sender, EventArgs e)
{
using (SPSite site = new SPSite(requestUrl))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = null;
string listName = txtListName.Text.Trim();
// Check whether the list already exists
try
{
list = web.Lists[listName];
}
catch (ArgumentException)
{
}
if (list == null)
{
Guid listId = web.Lists.Add(listName, "All our books",SPListTemplateType.GenericList);
list = web.Lists[listId];
list.OnQuickLaunch = true;
list.Update();
}
}
}
}
/// 新建列表
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btn_Click(object sender, EventArgs e)
{
using (SPSite site = new SPSite(requestUrl))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = null;
string listName = txtListName.Text.Trim();
// Check whether the list already exists
try
{
list = web.Lists[listName];
}
catch (ArgumentException)
{
}
if (list == null)
{
Guid listId = web.Lists.Add(listName, "All our books",SPListTemplateType.GenericList);
list = web.Lists[listId];
list.OnQuickLaunch = true;
list.Update();
}
}
}
}