I have a bit of code returning some results which works fine however the editor need the option to change the results order depending on the page they are being listed.
Assumed it would be pretty simple but have been going round in circlues for a while now.
This code works:
if (Model.Results.BlogPostList.Any())
{
var sortedList = Model.Results.BlogPostList.OrderByDescending(x => x.Value<DateTime>("postDate"));
@foreach(var item in sortedList)
{
<p>results</p>
}
}
But would like to add something like to the code:
if (sortOrder == "Acending")
{
var sortedList = Model.SearchResults.BlogPostList.OrderBy(x => x.Value<DateTime>("postDate"));
}
However when I do add an if statment in here end up with the error: CS0173: Type of conditional expression cannot be determined because there is no implicit conversion between 'string' and 'method group'
When I add a conditional stament to the working code this is the error it's been giving:
Line 61:
Line 62:
Line 63: @foreach(var item in sortedList)
Line 64:
Line 65: {
error CS0103: The name 'sortedList' does not exist in the current context
error CS0173: Type of conditional expression cannot be determined because there is no implicit conversion between 'string' and 'method group'
Dynamic Sort Order
Hi
I have a bit of code returning some results which works fine however the editor need the option to change the results order depending on the page they are being listed.
Assumed it would be pretty simple but have been going round in circlues for a while now.
This code works:
But would like to add something like to the code:
However when I do add an if statment in here end up with the error: CS0173: Type of conditional expression cannot be determined because there is no implicit conversion between 'string' and 'method group'
Any Ideas what I'm missing?
Thanks
Could you post a bit more of the error you get.
It seems you are comparing a string against a method, but a bit had to see in your posted code where it is.
Thanks a lot for taking the time to reply.
When I add a conditional stament to the working code this is the error it's been giving:
is working on a reply...