Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I would like to add a webpart to my page with all the Titles of all my lists from contenttype X. How can I implement this?

For example I have 4 lists which are using contenttype X:

ListA
ListB
ListC
ListD

In my webpart I would like to have all these list instances with some a href to the list:

ListA
ListB
ListC
ListD
share|improve this question

1 Answer 1

Use SPContentTypeUsage.GetUsages method to get the list instances where a content type has been used. Example:

SPContentType ct = site.RootWeb.ContentTypes["ContentType"];
IList<SPContentTypeUsage> usages = SPContentTypeUsage.GetUsages(ct);
foreach (SPContentTypeUsage usage in usages)
{
    if (usage.IsUrlToList)
    {
        SPList list = web.GetList(usage.Url);       
    }
}
share|improve this answer
    
Thanks for the solution programmatically. I am looking for some solution OOTB or in SharePoint designer. –  KHA Apr 28 at 9:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.