Let’s say I have 24 items that I want to display in a page using
some kind of paging (these items are contents from my umbraco backlog)
On initial load I want to load only 5 items and have a ‘see
more’ button/link to display the next 5 items (when clicked)
At this point it should only show initial 5 and the next 5
items on the page, and upon every ‘see more’ button/link click it should continue
to append the current number of items + 5, until there is no more items (in
this case 24 items are all displayed).
I have tried doing the following code (not sure where I am going wrong, or if there is a better solution to do this)
int count = 5; //so it can initally load 5 items int pages = Convert.ToInt32(this.Request.QueryString["pages"]); int page = pages * 5; //ex. page 1 load 5 items, page 2 load 10 items
if (items.Count() > 0) { foreach (Item item in items) { if (!this.Request.QueryString["pages"] == pages.ToString()) { if (count % 5 != 0 && remainingItems > 0 || count == 5) { HTML CODE
remainingItems--; count++;
}
else if (count % 5 == 0 && remainingItems > 0) { HTML Code
pages++; //this appends the page number remainingItem--;
Paging through a query result - help
Let’s say I have 24 items that I want to display in a page using some kind of paging (these items are contents from my umbraco backlog)
On initial load I want to load only 5 items and have a ‘see more’ button/link to display the next 5 items (when clicked)
At this point it should only show initial 5 and the next 5 items on the page, and upon every ‘see more’ button/link click it should continue to append the current number of items + 5, until there is no more items (in this case 24 items are all displayed).
I have tried doing the following code (not sure where I am going wrong, or if there is a better solution to do this)
Hi Abdo,
Here you can find a good reference for paging
http://www.diplo.co.uk/blog/2011/6/21/creating-a-paged-list-in-umbraco-using-razor.aspx
Anyways here is how i usually do it
fantastic!! thanks alot Fuji
is working on a reply...