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

I want to build search criteria by using SPQuery object that searches a list. On application page, there are two textbox Controls, 2 combobox Controls and 2 people picker Controls. The search criteria is based on user input. Users will use any or all of these Control values to search records. I could not find an efficient way to solve this issue. I need some good links or suggestion to solve this.

share|improve this question
up vote 0 down vote accepted

I don't know how to dynamic query using CAML..

but u can do using linq query.

for eg.

var query = from SPListItem objItem in objSPList.Items
                        where onvert.ToString(objItem["Status"]).Equals("Completed")
                        && Convert.ToString(objItem["ItemType"]).Equals("Current")
                        select new
                            ID = Convert.ToString(objItem["ID"]),
                            Title = Convert.ToString(objItem["Title"]),
                            Status = Convert.ToString(objItem["Status"])

foreach(var oItem in query)

you can put create dynamic query after where clause based on condition.

some links are which helps u..

share|improve this answer

CAMLEX.NET is good tool to solve you task.

From documentation: Dynamic filtering conditions

share|improve this answer

Your Answer


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

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