【发布时间】:2016-04-01 16:31:15
【问题描述】:
我的 MVC 5 应用程序出现错误:
CS1061:“IPagedList”不包含“TargetContact”的定义,并且找不到接受“IPagedList”类型的第一个参数的扩展方法“TargetContact”(您是否缺少 using 指令或程序集引用?)
我在这里看到了答案,但我仍然没有完成:( 这可能很容易解决。
public ActionResult Index(string searchTargetContact = null, int page = 1)
{
var model =
from r in db.Outreach
orderby r.TargetContact descending
where (r.TargetContact.StartsWith(searchTargetContact) || searchTargetContact == null)
select new Models.OutreachSetListViewModel
{
TargetContact = r.TargetContact,
NextOutreachStep = r.NextOutreachStep,
GoalOfOutreach = r.GoalOfOutreach,
};
model.ToPagedList(page, 10);
return View(model);
namespace WebApplication11.Models
{
public class OutreachSetListViewModel
{
public string NextOutreachStep { get; set; }
public string TargetContact { get; set; }
public string GoalOfOutreach { get; set; }
}
}
@model IPagedList<OutreachSetListViewModel>
<table class="table" id="networkingList">
<tr>
<th>@Html.DisplayNameFor(model => model.TargetContact)</th>
<th>@Html.DisplayNameFor(model => model.NextOutreachStep)</th>
<th>@Html.DisplayNameFor(model => model.GoalOfOutreach)</th>
<th></th>
</tr>
@foreach (var item in Model)
{
<tr>
<td>@Html.DisplayFor(modelItem => item.TargetContact)</td>
<td>@Html.DisplayFor(modelItem => item.NextOutreachStep)</td>
<td>@Html.DisplayFor(modelItem => item.GoalOfOutreach)</td>
</tr>
}
【问题讨论】:
标签: asp.net-mvc-4