質問

私は

役に立ちましたか?

解決

How about creating the SPQuery object using the constructor where you can pass the appropriate SPView.

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spquery.spquery.aspx

You could then add a query to include the appropriate items, something like:-

var query = new SPQuery(spView); 

query.Query = String.Format("<Where><Eq><FieldRef Name='Title'/><Value Type='Text'>{0}</Value></Eq></Where>", keyword);

SPListItemCollection listItems = oList.GetItems(query);

他のヒント

If the SPQuery returns all the items of the List, then in most cases the QueryString is simply wrong. The (in my optionion weird) default behaviour is, that in case of wrong QueryStrings a Caml-Query returns ALL the items.

For example of a common mistake: The QueryString for SPQuery.Query must NOT include the "<Query>"-Tag. If so, it returns all items and ignores the Where-Clause completely.

ライセンス: CC-BY-SA帰属
所属していません sharepoint.stackexchange
scroll top