Hello I have this code that goes through the SharePoint site and it looks at all the lists, and returns then to a label. Basically I want it to only grab the current site lists only, and not any subsites under right now I have my SP site like this:
Main Site
-Documents
-Images
-MyListA
--Engineering (subSite)
---Documents
---Images
---MyList10
It duplicates Images Documents the normal lists and MyList10 shows up. All I want is Documents Images and MyListA Thank You
string webUrl = SPContext.Current.Site.Url.ToString();
using (SPWeb oWebsite = new SPSite(webUrl).OpenWeb())
{
SPWebCollection subSites = oWebsite.Webs;
foreach (SPWeb subSite in subSites)
{
SPListCollection collList = subSite.Lists;
foreach (SPList oList in collList)
{
Label1.Text = SPEncode.HtmlEncode(oList.Title);
}
subSite.Close();
}
}