Hi I have a MVC View and I was wanting to make a ActionLink.
In my view I have:
@foreach (var item in Model.Invoices) {
<tr>
<td>
@Html.ActionLink(modelItem => item.Organisation.Name, "EditInvoice(" + item.Id + ")", "InvoiceController")
</td>
<td>
@Html.DisplayFor(modelItem => item.InvoiceDate)
</td>
<td>
@Html.DisplayFor(modelItem => item.TotalExcludingGst)
</td>
</tr>
}
</table>
The ActionLink method first parameter is causing some problems. I want to set the text to the Organisation Name. However it is throwing the error ‘Cannot convert lambda expression to type ‘string’ because it is not a delegate type’. The name property is already a string so I’m not sure what the reference is about.
Anybody know a way round this error?
Just pass the linkText argument as a string.
I think you will also need to correct the actionName and controllerName arguments and pass the ID in the routeValue argument. Something like: