我已经从控制器传递了值
public ActionResult Index(int? Page, string sortcol="ID", string sortorder="ASC", string firstname = "", string lastname = "", string emailaddress = "")
{
int TotalPages = 0;
var userlist = ur.GetUsersList(firstname, lastname, emailaddress, Page ?? 1, PageSize,out TotalPages, sortcol, sortorder);
ViewBag.PageIndex = 1;
ViewData["TotalPages"] = TotalPages.ToString();
if (Request.IsAjaxRequest())
{
return PartialView("ListUsers", userlist);
}
return View(userlist);
}
在我的父母看来:
@Html.Partial("ListUsers", Model, ViewData)
在我的子视图(列表用户)中:
@ViewData["TotalPages"]
我无法获得 Viewdata totalpages 的值。为什么会这样?它总是返回零。