you can do this way:
@Html.ActionLink(item.EMP_ID.ToString(), "OfficerReport", new { id = item.EMP_ID })
parameter 1) Link Text
parameter 2) Action Name
parameter 3) route values
Domanda
I have a clickable link that must invoke my sql statement , however my field is an integer and ActionLink will stops and gives me an error that my item.Emp_ID is not a string.
In MVC4 C# is there any other ways that I can create a link to invoke my sql statement??
@Html.ActionLink(item.EMP_ID, "OfficerReport", new { id = item.EMP_ID })
Thank you.
Soluzione
you can do this way:
@Html.ActionLink(item.EMP_ID.ToString(), "OfficerReport", new { id = item.EMP_ID })
parameter 1) Link Text
parameter 2) Action Name
parameter 3) route values
Altri suggerimenti
Add ToString at the end if EMP_ID as shown below
@Html.ActionLink(item.EMP_ID.ToString(), "OfficerReport", new { id = item.EMP_ID });
More Information :-
@Html.ActionLink("Click here", // <-- Link text
"About", // <-- Action Method Name
"Home", // <-- Controller Name
null, // <-- Route value
null // <-- htmlArguments
)