?
Solved

Filter custom list from all sharepoint lists

Posted on 2011-03-22
4
Medium Priority
?
594 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 32

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 32

Accepted Solution

by:
Jamie McAllister MVP earned 1500 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Last week I faced a strange issue recently, i have deployed SharePoint 2003 servers for one project and one of the requirements was to open SharePoint site from same server. when i was trying to open site from the same server i was getting authentic…
In case you ever have to remove a faulty web part from a page , add the following to the end of the page url ?contents=1
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

771 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