[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Filter custom list from all sharepoint lists

Posted on 2011-03-22
4
Medium Priority
?
599 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

650 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