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