MVC Razor View - Using Model in .EditorFor() and for in String.Format()
<td>@Html.EditorFor(Model => Model.Loan)</td>
I have that in the beginning of the view, and then after that, I have a statement like
The interest rate for the loan is @String.Format("{0:c}", Model.Interest).
It gives me error "'Model' conflicts with the declaration 'System.Web.Mvc.WebViewPage.Model'"
I also tried
The interest rate for the loan is @String.Format("{0:c}", Model => Model.Interest).
开发者_C百科It errored "Cannot convert lambda expression to type 'object[]' because it is not a delegate type"
If I remove the EditorFor, it doesn't error for the next statement.
Is there any way I can do both, other than adding the model to the ViewBag.
The argument name in the lambda expression is conflicting with the existing Model
property.
You need to use a different argument name, such as @Html.EditorFor(m => m.Loan)
精彩评论