Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I?m trying to get

how can I get the query but on the client context?

   SPWeb webRoot = scSite.OpenWeb();                

  SPListItem selectedItem = (from SPListItem item in webRoot.Lists["ContentIndex"].Items

I tried with:

SP.ListItem selectedItem = (from SP.List item in     context.Web.Lists["ContentIndex"].Items  

but I got a error because the context object has not the ".Item" property at the end!

Any idea?

share|improve this question

1 Answer 1

From the SP.List object, there are two methods to get items. getItems and getItemsById. If you don't know the Id of the item you want, you have to first create a new SP.CamlQuery object, then set the viewXml property the query object, then use the query as a parameter in the getItems method. You have to load this collection into the context and execute the query.

Here is a good resource about dealing with list using javascript and the client object model. It would be a little different in C#, but the concepts are pretty much the same. http://msdn.microsoft.com/en-us/library/gg701783.aspx

share|improve this answer

Your Answer

 
discard

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.