我在许多操作中都在项目中使用PagedList,但一切都很好,但我还是束手无策。获取数据列表后有46个项目,在操作和查看时一切正常。当启动5个项目中的foreach列表或4索引引发对象引用。App_Web_fwr4tzo0.dll中发生了'System.NullReferenceException'类型的异常,但未在用户代码中处理。] 2] 3] {{3} }
其他信息:对象引用未设置为对象的实例。
List<DocumentsViewModel> dsListDocumentsPublish = null;
this._ducumentsService.DocumentSearcher.SearchDocuments(out dsListDocumentsPublish);
var Documents = from n in dsListDocumentsPublish
select n;
int pageSize = Convert.ToInt32(ConfigurationManager.AppSettings["pagesModal"]);
int pageNumber = (page ?? 1);
ViewBag.SearchModel = null;
return PartialView("_AssociatedDocumentsPartial",Documents.ToPagedList(pageNumber,5));
@model PagedList.IPagedList<LawyerPortalPlovdiv.Models.Admin.DocumentsViewModel>
@{
ViewBag.Title = "";
ViewBag.RightSideTitle = "";
var pagenation = "Страница";
var action = ViewContext.Controller.ValueProvider.GetValue("action").RawValue.ToString();
var searchModel = ViewBag.SearchModel as DocumentsSearchModel;
}
<div class="modal fade p-0 " id="AllDocs" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true" data-backdrop="static" data-keyboard="false" style="top:150px;">
<div class="modal-dialog" role="document">
<div class="modal-content" id="allDocsContent">
@if (User.IsInRole("ManageAdministration") && Model != null)
{
<div class="row ">
<div class="col-md-8">
<div id="ducumentTable" class="table-responsive-md">
<table class="table table-hover" style="overflow-y: scroll; overflow-x: hidden">
<thead class="col-md-12" style="background-color: darkred; font-family: Arial; font-size: 10px;color:white">
<tr style="border-top: none">
<th class="col-md-2">ДАТА</th>
<th class="col-md-4">ДОКУМЕНТ</th>
<th class="col-md-6">ИМЕ НА ФАЙЛ</th>
</tr>
</thead>
<tbody>
@foreach (var prot in Model)
{
<tr class="persons text-center">
<td class="p-0 col-md-2"><span class="date2">@prot.Date.ToShortDateString()</span></td>
<td class="col-md-4">@prot.Title</td>
<td class=" col-md-6" >@prot.FileName</td>
</tr>
}