C# 为DisplayFor值创建ActionLink

C# 为DisplayFor值创建ActionLink,c#,asp.net-mvc-5,actionlink,html.actionlink,displayfor,C#,Asp.net Mvc 5,Actionlink,Html.actionlink,Displayfor,我已经编写了一个C#MVC 5互联网应用程序,并对视图中的ActionLink提出了一个问题 我有以下代码: <td> @Html.DisplayFor(modelItem => item.mapLocations.Count) </td> @Html.ActionLink(item.mapLocations.Count, "Index", "MapLocation", new { mapCompanyid = item.Id }, null) 我得到一

我已经编写了一个C#MVC 5互联网应用程序,并对
视图中的
ActionLink
提出了一个问题

我有以下代码:

<td>
    @Html.DisplayFor(modelItem => item.mapLocations.Count)
</td>
@Html.ActionLink(item.mapLocations.Count, "Index", "MapLocation", new { mapCompanyid = item.Id }, null)
我得到一个编译错误,如下所示:

Compiler Error Message: CS1928: 'System.Web.Mvc.HtmlHelper<CanFindLocation.ViewModels.MapCompaniesViewModel>' does not contain a definition for 'ActionLink' and the best extension method overload 'System.Web.Mvc.Html.LinkExtensions.ActionLink(System.Web.Mvc.HtmlHelper, string, string, string, object, object)' has some invalid arguments
这将有助于:

@Html.ActionLink(item.mapLocations.Count, "// action name //", "// controller name //", new{ mapCompanyid = item.Id  }, new{ // html attributes // })
只需与Actionlink匹配,其结构应如下所示:-

Html.ActionLink(item.mapLocations.Count, //  <--Title
            "Index",   // <-- ActionMethod
            "MapLocation",  // <-- Controller Name.
            new { mapCompanyid = item.Id }, // <-- Route arguments.
            null  // <-- htmlArguments.
            )

Html.ActionLink(item.mapLocations.Count,//item.mapLocations.Count处于循环中,因此无法工作。是否要在actionlink的标题或路由参数中使用item.mapLocations.Count???我想将计数值显示为操作链接的文本。你能看一下我的编辑吗?我已经编码了,但帖子中出现了错误。这不是possible…请尝试@item.mapLocations.Count而不是item.mapLocations.Count
Html.ActionLink(item.mapLocations.Count, //  <--Title
            "Index",   // <-- ActionMethod
            "MapLocation",  // <-- Controller Name.
            new { mapCompanyid = item.Id }, // <-- Route arguments.
            null  // <-- htmlArguments.
            )