hi every one
My paging code is skipping every second link, like lin 1 works but link 2 dont and then link 3 work but link 4 dont and so on what have i done wrong i cant see it
My code
@{
int pageSize = 1; // How many items per page
int page; // The page we are viewing
/* Set up parameters */
if (!int.TryParse(Request.QueryString["page"], out page))
{
page = 1;
}
/* This is your basic query to select the nodes you want */
var nodes = Model.Content.Children.Where(x => x.DocumentTypeAlias == "nyBegivenhed").OrderBy("CreateDate desc");
int totalNodes = nodes.Count();
int totalPages = (int)Math.Ceiling((double)totalNodes / (double)pageSize);
/* Bounds checking */
if (page > totalPages)
{
page = totalPages;
}
else if (page < 1)
{
page = 1;
}
<div class="container">
<div class="row">
<div class="col-lg-8 col-md-10 mx-auto">
<h1 class="main-page-heading">@Umbraco.Field("navnNyBegivenhed")</h1>
@foreach (var item in nodes.Skip((page - 1) * pageSize).Take(pageSize))
{
<div class="post-preview">
<a href="@item.Url">
<h2 class="post-title">@item.GetPropertyValue("navnNyBegivenhed")</h2>
@*<h2 class="post-title">@item.Name</h2>*@
</a>
<p class="post-meta">Skrevet af: @Umbraco.Field("creatorName") Den. @Umbraco.Field("createDate")</p>
</div>
<hr />
}
@{
if (totalPages > 1)
{
<div class="pagination-class">
<ul class="pagination">
@if (page > 1)
{
<li><a style="margin-right: 10px;" class="btn btn-danger btn-pagination" href="?page=@(page-1)">Tilbage</a></li>
}
@for (int p = 1; p < totalPages + 1; p++)
{
<li style="margin-right: 10px;" class="@(p == page ? "active" : string.Empty) btn btn-danger btn-pagination">
<a href="?page=@p">@p</a>
</li>
}
@if (page < totalPages)
{
<li><a style="margin-right: 10px;" class="btn btn-danger btn-pagination" href="?page=@(page+1)">Næste</a></li>
}
</ul>
</div>
}
}
</div>
</div>
</div>
e.g. is every second link in the pagination output missing? Or are they all showing but when you click on certain links it throws an error (in which case, is there an error message or screenshot you can post)?
Why is my paging skipping every second link
hi every one My paging code is skipping every second link, like lin 1 works but link 2 dont and then link 3 work but link 4 dont and so on what have i done wrong i cant see it
My code
What do you mean when you say it doesn't work?
e.g. is every second link in the pagination output missing? Or are they all showing but when you click on certain links it throws an error (in which case, is there an error message or screenshot you can post)?
Or something else?
is working on a reply...