Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Sharepoint SPQuery

  Asked By: Damaris    Date: Apr 18    Category: Sharepoint    Views: 852

For instance, let us take a State List which holds all the states of India. States are grouped under different zones i.e. North, South, East & West. If I need to retrieve all the States for North zone then my SP Query would look somewhat like,

SPQuery stateQuery = new SPQuery();
stateQuery.Query =
"<Where><Eq><FieldRef Name=\"Zone\"/><Value Type=\"Text\">North</Value></Eq></Where>";
SPListItemCollection stateCol = StateList.GetItems(stateQuery);

In the code above the StateCollection object gets populated with the States only related to North zone. You can then bind this collection to a GridView or DataList or any other similar controls to view the actual values.




No Answers Found. Be the First, To Post Answer.

Didn't find what you were looking for? Find more on Sharepoint SPQuery Or get search suggestion and latest updates.