0

我如何使用 MVC Razor 增加和减少锚标记内的@currentpage 值?

@{
    double pagesize = Math.Ceiling(Convert.ToDouble(@ViewData["count"]) / 10);
    int currentpage = Convert.ToInt32(@ViewData["id"]);
}
<a href="/Home/Index/@currentpage-1">Prev</a>
<a href="/Home/Index/@currentpage+1">Next</a>
4

3 回答 3

2
<a href="/Home/Index/@(currentpage-1)">Prev</a>
<a href="/Home/Index/@(currentpage+1)">Next</a>
于 2012-05-17T07:47:54.187 回答
1

用这个

 @{
        double pagesize = Math.Ceiling(Convert.ToDouble(@ViewData["count"]) / 10);
        int currentpage = Convert.ToInt32(@ViewData["id"]);
        int nextpage=currentpage+1;
        int Prevpage=currentpage-1;
    }
    <a href="/Home/Index/@Prevpage">Prev</a>
    <a href="/Home/Index/@nextpage">Next</a>
于 2012-05-17T07:47:18.447 回答
0

我没有尝试过,但这样的事情应该可以工作:

@Html.ActionLink("Next", "Index", "Home", new { id = (Convert.ToInt32(@ViewData["id"]) + 1) }, "")
@Html.ActionLink("Prev", "Index", "Home", new { id = (Convert.ToInt32(@ViewData["id"]) - 1) }, "")
于 2012-05-17T07:46:31.000 回答