Я пытаюсь добавить пейджинг к своему виду бритвы. Функция управления содержит модель представления, а представление также имеет частичное представление для визуализации. Оно выдает ошибки в Model.FilterServices и Model.CustomerProfile и DisplayFor.
Функция поиска контроллера:
public ActionResult Search(FilterServicesViewModel sp , int? page)
{
var data = from profile in _context.Customers
join service in _context.CustomerServices
on profile.strUserID equals service.strUserID
where profile.CustomerTypeId == 1
select profile;
data = data.OrderBy(profile => profile.Name);
int pageSize = 3;
int pageNumber = (page ?? 1);
var dataPaged = data.ToPagedList(pageNumber, pageSize);
IEnumerable<SelectListItem> items = _context.ServicesOffered.Select(c => new SelectListItem
{
Value = c.lngServiceID.ToString(),
Text = c.Name
});
var serviceProviderViewModel = new ServiceProvider
{
FilterServices = new FilterServicesViewModel(),
CustomerServices = new CustomerServices()
};
serviceProviderViewModel.FilterServices.FindService = sp.FindService;
serviceProviderViewModel.FilterServices.ServicesOffered = items;
serviceProviderViewModel.CustomerProfiles = dataPaged;
return View("SearchServiceProviders", serviceProviderViewModel);
}
Razor View Page:
@model PagedList.IPagedList<DatabaseMVCPractice.ViewModels.ServiceProvider>
@using PagedList.Mvc;
@using PagedList;
<link href="~/Content/PagedList.css" rel="stylesheet" type="text/css" />
@{
ViewBag.Title = "SearchServiceProviders";
}
<h2>Search Service Providers</h2>
@{
Html.RenderPartial("_FilterView",Model.FilterServices);
}
<table class="table">
<tr>
<th></th>
</tr>
@foreach (var item in Model.CustomerProfiles)
{
<tr>
<td>
<img src="@Url.Content("~/Images/Thumbs/"+item.ProfileImage)" alt="Image" />
</td>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.Address)
</td>
<td>
@Html.DisplayFor(modelItem => item.CustomerType)
</td>
<td>
@Html.DisplayFor(modelItem => item.WhenDate)
</td>
</tr>
}
</table>
<br />
Page @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) of @Model.PageCount
@Html.PagedListPager(Model, page => Url.Action("Index",
new { page, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter }))
Показать модель Класс:
public class ServiceProvider
{
public CustomerProfile Customer { get; set; }
public IEnumerable<CustomerProfile> CustomerProfiles { get; set; }
public CustomerServices CustomerServices { get; set; }
public FilterServicesViewModel FilterServices { get; set; }
}
Я получаю сообщение об ошибке:
IPagedList<ServiceProvider>' does not contain a definition for 'CustomerProfiles' and no extension method 'CustomerProfiles' accepting a first argument of type 'IPagedList<ServiceProvider>' could be found (are you missing a using directive or an assembly
Выдает ошибки на Model.FilterServices и Model.CustomerProfile и DisplayFor