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