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?
|
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? |
|||
|
|
|
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. |
||||
|
|
|
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. |
|||||
|
|
Permissions might be the issue. I ran into the same thing, and it turned out that I forgot to make the list accessible. |
|||
|
|
|
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.... |
|||
|
|
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 |
|||
|
|