我在Microsoft上看到了一篇文章,介绍如何在c#中添加分页。循序渐进地遵循本文,我在适应我的观点时遇到了一些困难。在给出一些代码的同时,我将尝试更好地解释自己:
控制器:
[HttpGet("searchmovie")]
public IActionResult Search(string option, string searchmovie, int? page, string currentFilter)
{
if (search != null)
{
page = 1;
}
else
{
search = currentFilter;
}
SearchViewModel data = new SearchViewModel();
int pageSize = 4;
IEnumerable<SearchDataItemViewModel> searchMovie =
Mapper.Map<IEnumerable<SearchDataItemViewModel>>(_unitOfWork.Movies.GetByString(search));
var searchMoviesP = Helpers.PaginatedList<SearchDataItemViewModel>.CreateAsync(searchMovie,page ?? 1, pageSize);
data.SearchMovie = searchMoviesP;
return View("Search", data));
}
这是我的看法:
<li class="tab-2 tabs-list-item">
<ul>
<li>
<h3 class="tabs-header">LoremIpsum</h3>
<ul class="content-full col-1">
@foreach (var mv in Model.SearchMovie)
{
if (mv != null)
{
<li>
<div class="to-do-desc">
<p>@mv.Text</p>
</div>
</li>
}
else
{
<li><p>No results</p></li>
}
}
</ul>
</li>
</ul>
关于Microsoft文档,我对应该传递给视图的哪些模型组件有任何想法吗?被卡在这里了一段时间,所以一些精灵将不胜感激谢谢!!!
陪伴而非守候
相关分类