Вопрос

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