What is the syntax for including model properties in Html.ActionLink?

For example, I have the following code inside foreach to create a table. One of the columns has a link "Click here to view more detailed information." The PurchaseOrderNumber number should create a hyperlink that points to the details page and pass the PurchaseOrderNumber number. Example: / Sales / Details / 7000

    <td>
        @Html.ActionLink("Details", "Index", @Html.DisplayFor(m => item.PurchaseOrderNumber))
    </td>

Instead, it only creates hyperlinks in / Sales? Length = 5

How to do it right?

+4
source share
1 answer

Assuming your controller Salesname, action name Details, and parameter name id:

@Html.ActionLink("Click here for more details",
                 "Details",
                 "Sales",
                 new { id = item.PurchaseOrderNumber }, null)

See MSDN

+2
source

All Articles