Solved

Filter custom list from all sharepoint lists

Posted on 2011-03-22
4
567 Views
Last Modified: 2012-05-11
In my scenario I am trying to get all the lists and display in checkbox list control(please see screenshot)
foreach (SharePointclientObj.List list in site.Lists)
{
System.Web.UI.WebControls.ListItem item = new System.Web.UI.WebControls.ListItem(list.Title, list.DefaultViewUrl);

checkBoxListName.Items.Add(item);
}

 

As this is working fine but its showing all the lists which are inbuit in sharepoint. I wanted to fetch only the custom list which are created by users in the sharepoint site.
How do I filter custome list from all the lists?

Screenshot.png
0
Comment
Question by:prdeshpande
  • 2
  • 2
4 Comments
 
LVL 31

Expert Comment

by:Jamie McAllister MVP
ID: 35187845
I've done this before and it wasn't easy. There's nothing in the object model to denote that it is a system list.

My solution was to gather the GUIDs of the out of the box lists (they are created by features and therefore are always the same), and I used that list of GUIDs to exclude those lists so that only my custom lists were shown.

I'm not aware of an easier solution than that.
0
 
LVL 1

Author Comment

by:prdeshpande
ID: 35188263
Hey thx for reply,Can you please elaborate on your statements or I appreciate if you can share me some code snippets
0
 
LVL 31

Accepted Solution

by:
Jamie McAllister MVP earned 500 total points
ID: 35188332
excludeListTemplates = new ArrayList();
          excludeListTemplates.Add("df31abb1-d432-4fa5-bdb1-25a2a5dd7e86");
          excludeListTemplates.Add("00bfea71-2062-426c-90bf-714c59600103");
          excludeListTemplates.Add("22a9ef51-737b-4ff2-9346-694633fe4416");
          excludeListTemplates.Add("00bfea71-a83e-497e-9ba0-7a5c597d0107");
          excludeListTemplates.Add("942d046c-fcf7-4901-ace0-7305b17c1c12");
          excludeListTemplates.Add("00bfea71-6a49-43fa-b535-d15c05500108");
          excludeListTemplates.Add("00bfea71-7e6d-4186-9ba8-c047ac750105");
          excludeListTemplates.Add("00bfea71-ec85-4903-972d-ebe475780106");
          excludeListTemplates.Add("00bfea71-a83e-497e-9ba0-7a5c597d0107");

          try
          {
              
              string output = string.Empty;

              foreach (SPList list in SPContext.Current.Site.RootWeb.Lists)
              {
                  if ((!list.Hidden) || (!chkFilterList.Checked))
                  {
                      //The following Template Feature Ids are excluded:
                      //Caml Query List:                df31abb1-d432-4fa5-bdb1-25a2a5dd7e86
                      //Links:                          00bfea71-2062-426c-90bf-714c59600103
                      //Pages:                          22a9ef51-737b-4ff2-9346-694633fe4416
                      //Tasks:                          00bfea71-a83e-497e-9ba0-7a5c597d0107
                      //Website Settings:               942d046c-fcf7-4901-ace0-7305b17c1c12
                      //Team Discussion:                00bfea71-6a49-43fa-b535-d15c05500108
                      //Contacts:                       00bfea71-7e6d-4186-9ba8-c047ac750105
                      //Events:                         00bfea71-ec85-4903-972d-ebe475780106
                      //Workflow Tasks:                 00bfea71-a83e-497e-9ba0-7a5c597d0107

                      if (!excludeListTemplates.Contains(list.TemplateFeatureId.ToString()) || (!chkFilterList.Checked))
                      {
                          drpLists.Items.Add(list.Title);
                      }

                  }
 
              }

              
          }
          catch (System.Exception)
          {
              //Handle It
          }

Open in new window

0
 
LVL 1

Author Closing Comment

by:prdeshpande
ID: 35229667
Gr8 Solution
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Sharepoint to FTP? 3 71
SharePoint JSOM error 7 68
How to check if column "Assigned To" group was changed in SharePoint 2010? 18 58
Working with SharePoint Data 8 54
The vision: A MegaMenu for a SharePoint portal home page The mission: Make it easy to maintain. Allow rich content and sub headers as well as standard links. Factor in frequent changes without involving developers or a lengthy Dev/Test/Prod rel…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question