エンティティ データ モデルを使用して MVC 4 でページネーションを作成したいと考えています。私のHome/NameDetailsPageは正常に動作し、一度にすべての行を返します。しかし、行が非常に多いため、このデータをページネーションで表示したいと思います。だから私はこのように試しました
public ActionResult NameDetailsPage(int page)
{
var context = new BlogContext();
IQueryable<string> list;
list = from m in context.Blogs.OrderBy(m => m.BlogId)
select m.Name;
ViewBag.total=list.ToArray().Length;
return View("NameDetails", list.Skip(page * 4).Take(4));
}
ここで、ページ番号は、次の 4 行を取得するために page*4 行をスキップすることを示しています。残念ながら、これらのエラーが見つかりました。
The parameters dictionary contains a null entry for parameter 'page' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult NameDetailsPage(Int32)' in 'webpro.Controllers.HomeController'.
An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
Parameter name: parameters
私は何をすべきか ?前もって感謝します。