繁体   English   中英

在数据库的MVC 4视图中显示有限的数据

[英]Display limited data in mvc 4 view from database

我正在开发一个在线图书购物网站,并在此网站上从数据库动态生成视图中显示图书及其描述。 但我想每页显示10本书,并在页面底部显示一个链接,以转到下一页以查看下10本书。 在这里,我附加了我的代码,它从数据库中获取所有数据,并一次在一个页面中显示所有书籍。 我如何在其中实现分页功能。

@{
    ViewBag.Title = "Contact";
}
@model IEnumerable<BusinessObject.Images>

<link href="../../css/style.css" rel="stylesheet" type="text/css" />
<div id="content">
<!-- Products -->
            <div class="products">
                <h3>Featured Products</h3>
                <ul>
@foreach (var item in Model)
{



                    <li>
                        <div class="product">
                        @Html.ActionLink(item.ImageName, "Details","Home", new { id = item.ImageId }, null) 

                                <span class="holder">
                                    <img src="@item.ImagePath" alt="">
                                    <span class="@item.ImageName" >@item.ImageName</span>
                                    <span class="author">by John Smith</span>
                                    <span class="description">Maecenas vehicula ante eu enim pharetra<br />scelerisque dignissim <br />sollicitudin nisi</span>
                                </span>
                            </a>
                            <a href="#" class="buy-btn">BUY NOW <span class="price"><span class="low">$</span>22<span class="high">00</span></span></a>
                        </div>
                    </li>}
                    </ul>
            </div>
            <div class="cl">&nbsp;</div>
            </div>

您只能从数据库本身中请求所需数量的记录-分页

检查链接

http://www.mssqltips.com/sqlservertip/1699/sql-server-stored-procedures-to-page-large-tables-or-queries/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM