私はオンラインの本のショッピングWebサイトを開発しています。ここでは、データベースから動的に生成されるビューに本とその説明を表示します。しかし、ページごとに10冊の本を表示し、ページの下部にリンクを表示して次のページに移動し、次の10冊の本を表示したいと思います。ここでは、データベースからすべてのデータをフェッチし、一度にすべての本を1つのページに表示するコードを添付しています。これでページング機能を実装する方法。
@{
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"> </div>
</div>