문제

I am new to ASPNET MVC. I have searched many hours but couldn't find a way to solve my simple problem.

For a Model with properties like "property1" "property2" "property3", I want to simplify the code in a View to something like:

for (i = 1; i <=3; i++) {
    @Html.EditorFor(model=>model.["property"+i];
}

How to replace the expression with custom names?

Thanks a lot

도움이 되었습니까?

해결책

You can use the weakly typed version :

for (i = 1; i <=3; i++) {
    @Html.Editor("property"+i);
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top