I need to list out the Custom list and library from SharePoint Sit开发者_开发知识库e? How to identify the content is comes under the custom created?
This code will help you
using (SPWeb web = currentSite.OpenWeb())
{
foreach (SPList list in web.Lists)
{
if (list.BaseType == SPBaseType.DocumentLibrary
&&
list.BaseTemplate == SPListTemplateType.DocumentLibrary
)
{
ListItem li = new ListItem();
li.Text = list.Title;
li.Value = list.ID.ToString();
}
else if(list.BaseType == SPBaseType.GenericList
&&
list.BaseTemplate == SPListTemplateType.GenericList)
{
ListItem li = new ListItem();
li.Text = list.Title;
li.Value = list.ID.ToString();
}
}
}
Below code should help you
SPList myList=SPContext.Current.Web.Lists["YourList"];
if (myList.BaseType == SPBaseType.DocumentLibrary)
{
//My List is Document Library
}
if (myList.BaseType == SPBaseType.GenericList)
{
//My List is Custom List
}
精彩评论