這是示例代碼.cshtml:
<li>
<a asp-route-currentPage="@(Model.CurrentPage -1)"
aria-label="Next">
<span aria-hidden="true"><</span>
<span >Previous</span>
</a>
</li>
<li>
<a asp-route-currentPage="@Model.TotalResults[0]"
aria-label="Last">
<span aria-hidden="true">>|</span>
<span >Last</span>
</a>
</li>

當我單擊下一個或上一個按鈕時,它不會添加或減去當前頁面值。
有什么辦法可以解決嗎?請告訴我。提前致謝
public int CurrentPage { get; set; } = 1;
public int Count { get; set; }
public int PageSize { get; set; } = 5;
public int TotalPages => (int)Math.Ceiling(decimal.Divide(Count, PageSize));
public bool EnablePrevious => CurrentPage > 1;
public bool EnableNext => CurrentPage < TotalPages;
public dynamic TotalResults;
public void OnGet(int CurrentPage)
{
if (CurrentPage == 0)
{
CurrentPage = 1;
}
ViewData["Title"] = "Transactions List";
Transactions = GetTransactions(CurrentPage);
}
uj5u.com熱心網友回復:
從您的方法的外觀來看OnGet,您沒有CurrentPage用新的值更新值。
public void OnGet(int CurrentPage)
{
...
this.CurrentPage = CurrentPage; // Added this
...
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/497169.html
