@if (item.hasTypes.Value == true) {
Html.ActionLink(item.marketGroupName, "Index", new { id = item.marketGroupID });
}
I have this so that if the hasTypes is true, it will create an actionlink. But the above code does not work. It is showing empty in those columns.
Html. ActionLink creates a hyperlink on a view page and the user clicks it to navigate to a new URL. It does not link to a view directly, rather it links to a controller's action.
ActionLink(HtmlHelper, String, String, Object, Object)Returns an anchor element (a element) for the specified link text, action, route values, and HTML attributes.
There is a difference. Html. ActionLink generates an <a href=".."></a> tag whereas Url. Action returns only an url.
I think you forgot an @
which is used to output:
@if (item.hasTypes.Value) {
@Html.ActionLink(item.marketGroupName, "Index", new { id = item.marketGroupID });
}
You need to actually render the link to the output. Your current code produces a link but doesn't actually do anything with it. Notice the extra @
below:
@if (item.hasTypes.Value == true) {
@Html.ActionLink(item.marketGroupName, "Index", new { id = item.marketGroupID });
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With