1
我正在尋求在從左到右的流程中使用簡短標題顯示我的圖像,而不是按順序佈局的gridview。我希望使用webgrid提供的分頁方式,以避免重新創建輪子。ASP.NET MVC3 - 僅分頁(不顯示WebGrid)
我評論過Leek的博客文章(http://msdn.microsoft.com/en-gb/magazine/hh288075.aspx)和Broer's(http://blog.bekijkhet.com/2011/03/mvc3 -webgrid-html-helper-paging.html),以確保我對webgrid的使用有了一個堅實的介紹,但是我不太瞭解如何在不使用webgrid的傳統佈局的情況下應用分頁。
我正在使用剃刀布局。
想法或想法?
我控制器當前:
public ActionResult Index(string cid)
{
Catalog item = new Catalog();
item.objConnection.Open();
OdbcDataReader reader = item.getCatalogItems(cid, 3);
List<Catalog> listItems = new List<Catalog>();
while (reader.Read())
{
Catalog i = new Catalog();
i.kitName = reader.GetValue(1).ToString();
i.catalogID = reader.GetValue(0).ToString();
ViewBag.CatalogName = reader.GetValue(0).ToString(); //TODO: change this to name once in place
listItems.Add(i);
}
ViewBag.ItemsPerCatagory = listItems.Count;
reader.Close();
item.objConnection.Close();
return View(listItems);
}
筆者認爲:
@model IEnumerable<MvcApplication1.Models.Catalog>
@{
ViewBag.Title = ViewBag.CatalogName;
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h2>@ViewBag.CatalogName (@ViewBag.ItemsPerCatagory) Items Available</h2>
<p>
Category will have a brief description here for seo purposes.
</p>
<p>
@foreach (var catalog in Model)
{
string imageUrl = "http://web3.naeir.org/images/Specials/" + @catalog.kitName + ".JPG";
<img [email protected] height="150px" width="150px" /> @Html.ActionLink(@catalog.kitName, "Details", "Product", new { cid = @catalog.catalogID, itemid = @catalog.kitName }, null)
}
</p>
我的解決方案是使用MVCPager [MVC尋呼網站](http://blogs.taiga.nl/martijn/2008/08/27/paging-with-aspnet-mvc/) – wintercyborg