I have this bit of code looping trough some nodes before pagination. I'm trying to sort the nodes based on a property before rendering the pages, but whenever I put OrderBy before the Skip or Take I get an error "Exception: System.FormatException: Input string was not in a correct format."
foreach (var item in items.Skip((pages -1)* pageSize).Take(pageSize).OrderBy("dateFiled desc"))
Hi Fuji, what ended up working for me was moving the OrderBy statement up in the declaration for "items", it seems that it should work both ways though no?
@if (startNodeID != null) { if (@filingGroup != null) { } @* Get the start node as a dynamic node *@ var startNode = Library.NodeById(startNodeID);
//Pagination var pageSize = 20; var pages = 1; int.TryParse(Request.QueryString["page"], out pages); var items = startNode.Children.Where("Visible").OrderBy("dateFiled desc"); var totalPages = (int)Math.Ceiling((double)items.Count() / (double)pageSize);
} if (startNode.Children.Where("Visible").Any()) {
else { foreach (var item in items.Skip((pages -1)* pageSize).Take(pageSize)) {
string filingDate = @item.dateFiled; int year = int.Parse(filingDate.Substring(0, 4)); int month = int.Parse(filingDate.Substring(4, 2)); int day = int.Parse(filingDate.Substring(6, 2));
OrderBy before Skip throws error
Hi,
I have this bit of code looping trough some nodes before pagination. I'm trying to sort the nodes based on a property before rendering the pages, but whenever I put OrderBy before the Skip or Take I get an error "Exception: System.FormatException: Input string was not in a correct format."
Anyone know why this would be?
Thanks!
Amir
Hi Amir,
It looks good to me, but can you please post your whole code ?
I have this working for me
Hi Fuji, what ended up working for me was moving the OrderBy statement up in the declaration for "items", it seems that it should work both ways though no?
Here's the code, shortened for brevity.
Great to know you got it working
is working on a reply...