Domanda

SPWeb _SPweb = _SPSite.OpenWeb();
SPList _SPlist = _SPweb.Lists[FL.ToString()];

SPQuery _spquery = new SPQuery();
_spquery.Query = "<Query><Where><Eq><FieldRef Name='Title'/><Value Type='Text'>now</Value></Eq></Where><OrderBy><FieldRef Name='Date_Of_x0020__Posted' Ascending='False' /></OrderBy></Query>";//"<Query><OrderBy><FieldRef Name='Date_Of_x0020__Posted' Ascending='false' /></OrderBy></Query>";///CAMLquery  for oderby posted date

 SPListItemCollection FaqCollection = _SPlist.GetItems(_spquery);

if (FaqCollection != null || FaqCollection.Count <= 0)
{    
   foreach (SPListItem item in FaqCollection)
    {    
    }
}

Code above is retrieving the data from a list but not ordering, it was working perfectly, but it's not working any more. What have I missed here?

È stato utile?

Soluzione

I think the problem is with including Query tag in your CAML. Just remove it.

Here is a snippet that should work:

<Where>
 <Eq>
   <FieldRef Name="Title" />
   <Value Type="Text">now</Value>
 </Eq>
</Where>
<OrderBy>
 <FieldRef Name="Date_Of_x0020__Posted" Ascending="False" />
</OrderBy>

Altri suggerimenti

OK try this:

"now";

This should work

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top