I have a SharePoint list named Employee Information. And this list has a view called View1. Is there a way wherein i can use Caml query on the View of the list?


Yes you can, below should help:

string query = "<Where>Your Query</Where>";

SPList empList = web.Lists["Employee Information"];

SPView view = empList.Views["View1"];

SPQuery qry = new SPQuery(view);

qry.Query = query;

SPListItemCollection items = empList.GetItems(qry);
| improve this answer | |
  • Do you think splitting large lists into views and using the above query would solve the problem of list view threshold where queries on the list fail? – luckydeveloper Mar 20 '14 at 12:15
  • I'm not sure actually.. Either it picks the View itself and than applies the rest of the Query.. Or for getting the View itself it queries the whole list.. But its worth a try! – Arsalan Adam Khatri Mar 20 '14 at 12:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.