SharePoint: SPList.GetItems(SPView).Count issue

I needed to get all the list items present in a list view. I tried to get the count using SPList.GetItems(SPView).Count. However, the maximum count it could return was whatever was saved in View Properties of Item Limit.  









using (SPSite site = new SPSite("http://sp2010:90"))
{
    SPWeb web = site.RootWeb;
    SPList list = web.Lists["Employees"];
    SPView view = list.Views["Fourty Above"];
    int itemCount = list.GetItems(view).Count;                
}

I had to modify the above code to use SPQuery and pass the SPView as parameter to it. The SPQuery.RowLimit needs to be set to zero to get all items. Following is the modified code:


SPWeb web = site.RootWeb;
SPList list = web.Lists["Employees"];
SPView view = list.Views["Fourty Above"];
SPQuery query = new SPQuery(view);
query.RowLimit = 0;
int itemCount = list.GetItems(query).Count; 

profile for Nadeem Yousuf at SharePoint Stack Exchange, Q&A for SharePoint enthusiasts

+