12-14-2006, 12:42 PM
I am creating a function which will display the page number for a post in a thread on my forum. To calculate the page number I divide the total posts by the page size.
Posts in Thread: 12
Page Size: 10
Page Number: 12/10 = 1.2
However when rounded off 1.2 becomes 1, whereas I need it to always round up. Is there a way of doing this?
12-14-2006, 03:11 PM
Math.Ceiling what you were looking for?
12-14-2006, 04:03 PM
Hello Curt and nikkiH,
Curt if you are using the PagedDataSource Class, you can use the CurrentPageIndex Property to get an output something like:
Page 2 of 8
lblPageNumber.Text = "Page " & (PagedData.CurrentPageIndex + 1) & " of " & PagedData.PageCount
In the above sample, PagedData is the instance of the PagedDataSource Class.
12-14-2006, 04:05 PM
This is for links to posts such as the one at the bottom of my homepage:
Instead of the thread links going to the first post I need to find a way of getting the page number. I have all the code done for it, I just need to find a way of rounding up.
12-14-2006, 04:22 PM
nikkiH solution will do the job:
Math.Ceiling(2.2) = 3
Math.Ceiling(2.7) = 3
Math.Ceiling(2.0) = 2
12-14-2006, 04:32 PM
Thats worked great :D
Thank you to both you.