后台魔方对我们单元表进行了管理,因来一是超过400字符的他作了隐藏,同时显示格式不是我想要的,我们开始工作吧。
创建前台控制器
- 在项目前台控制器下,增加一个DLS的控制器
然后增加一个历史的要点表的LIST方法 ,需要用到分页
/// <summary>
/// 历史单元要点的清单展示
/// </summary>
/// <returns></returns>
public IActionResult LishiYaoDianList(PageParameter page)
{
//其实想用参数来搜索的方法选择学科的,以后增加化学这些就方便了,但后来想到算了,理科不给他弄了
var xxx = new PageParameter();
xxx.PageSize = 10;
xxx.PageIndex = page.PageIndex;
xxx.RetrieveTotalCount = true;
string subjectname = "历史";
ViewBag.pagetitle = subjectname;
xxx.OrderBy = "ID asc";
var enradingtimulist = SubjectUnit.FindAll(SubjectUnit._.SubjectName == subjectname, xxx);
ViewBag.PageIndex = page.PageIndex;
ViewBag.PageSize = 10;
ViewBag.PageCount = xxx.PageCount;
ViewBag.TotalCount = xxx.TotalCount;
////如果分页看完,则跳到另一个view去
//if (page.PageIndex > xxx.PageCount)
//{
// return RedirectToAction("YuReadNav", "YuOption");
//}
///返回值,读出应有的文章内容
return View(enradingtimulist);
}
然后前台 ``` @model IList
@ViewBag.pagetitle 的列表
@foreach (var item in Model) {
<div class="panel panel-default">
<div class="panel-heading left">
<h3 class="panel-title"> @Html.DisplayFor(modelItem => item.Unit)</h3>
<div style="color:#0094ff;line-height:30px;"> @Html.DisplayFor(modelItem => item.KeyPoints)</div>
</div>
<div class="panel-body left" id="content">
@Html.Raw(item.KeyPointsList)
</div>
</div>
}
@{
//var page = new NewLife.Data.PageParameter();
//page.PageSize = 2 ;
var xxx = Convert.ToInt32(ViewBag.PageIndex) - 1;
var yyy = Convert.ToInt32(ViewBag.PageIndex) + 1;
<div>
<a asp-action="LishiYaoDianList" asp-route-PageIndex=@xxx>上一页</a>
<a asp-action="LishiYaoDianList" asp-route-PageIndex=@yyy>下一页</a> |共 @ViewBag.PageCount 页,共 @ViewBag.TotalCount 条
</div>
}
```- 结果