List all surveys programmatically in SharePoint 2010?
I need to change some permissions for all surveys in a SharePoint 2010 site collection, how can I list them?
For example to list document libraries I can do
SPSite oSiteCollection = SPContext.Current.S开发者_高级运维ite;
SPWebCollection collWebsite = oSiteCollection.AllWebs;
foreach (SPWeb web in collWebsite)
{
SPListCollection collList = web.Lists;
foreach (SPList oList in collList)
{
if (oList is SPDocumentLibrary)
{
// Do something
}
}
}
Thanks in advance.
As your if statement use
if (oList.BaseType == SPBaseType.Survey)
精彩评论