SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

A list on my site gives 2 when I call myList.ItemCount. But myList.Items.Count gives me zero and I can't access the items stored in the list. AllItems.aspx show me the two missing items.

Any ideas?

share|improve this question

I remember that @furuknap once pointed out that ItemCount and Items.Count are different in the way they treat SPFolders (inclusive and exclusive). Also, ItemCount is faster because it gets a static SPList property instead of building the SPListItemCollection object before counting its members.

share|improve this answer

I looked closely with Reflector and found this, SPList.Items returns the list items by running a query with Scope=Recursive ViewAttribute. I don't have enough time to do some research on the topic but simply running a query with no attributes gave me my items.

share|improve this answer
remember it is a best practice to use myList.ItemCount over myList.Items.Count, for performance reasons. Read more here… – Anders Rask Feb 23 '10 at 20:02

Permissions might be the issue. I ran into the same thing, and it turned out that I forgot to make the list accessible.

Why can't I access the items in a List even if the SPList.ItemCount is > 0? - StackOverflow

share|improve this answer

Check whether the user u logged in may not assigned in ur site collection..... i too meet the same problem.... now cleared.....

add the u user what u logged in to the site collection and then check it....

share|improve this answer
Welcome to SharePoint StackExchange. Although your answer may answer the question, links to blog posts often break, where as we won't be going anywhere for a long while. It's always a good idea to extract the useful parts for research if not all of it incase that happens (If it's not too long!) Please read the FAQ[1] for more information [1] – Hugh Wood Dec 2 '12 at 3:18

SPList.ItemCount is the efficient and recommended way to retrieve items count in a list.

However, It should be noted that this property is fine tuned for performance which may cause the side effect of returning unexpected count. So, if you need the exact count, you should use the poorer performing SPList.Items.Count or SPList.GetItems(SPQuery query).Count

share|improve this answer

SPList.ItemCount, which is count of all items in the list. SPList.Items.Count, which is count of completed tasks/Check In pages. (Means it avoid the incompleted items)

share|improve this answer

Your Answer


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