문제

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.

도움이 되었습니까?

해결책

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

다른 팁

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      
                 )
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top