I have coded a C# MVC 5 Internet Application and have a question about an ActionLink
in a View
.
I have the following code:
<td>
@Html.DisplayFor(modelItem => item.mapLocations.Count)
</td>
Is it possible to create an ActionLink
for this above displayed value?
Thanks in advance
EDIT
I have tried the following code:
@Html.ActionLink(item.mapLocations.Count, "Index", "MapLocation", new { mapCompanyid = item.Id }, null)
I am getting a compilation error as follows:
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
EDIT2
Do I need the DisplayFor code to display the value in the ActionLink?
Maybe something like this:
@Html.ActionLink(Html.DisplayFor(modelItem => item.mapLocations.Count), "Index", "MapLocation", new { mapCompanyid = item.Id }, null)
This will work :-
Just match your Actionlink it's structure should look like below :-