3
,我发现了以下错误:Html.DisplayFor编译错误 - MVC 2
The type arguments for method 'System.Web.Mvc.Html.DisplayExtensions.DisplayFor<TModel,TValue>(System.Web.Mvc.HtmlHelper<TModel>, System.Linq.Expressions.Expression<System.Func<TModel,TValue>>, string)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
这里是我的局部视图:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<MyApp.Data.Person>" %>
<fieldset> <legend>Information</legend> <div class="display-label">ID</div> <div class="display-field"><%: Model.ID %></div><br /> <div class="display-label">Name</div> <div class="display-field"><%: Model.Name %></div><br /> <div class="display-label">DOB</div> <div class="display-field"><%: String.Format("{0:g}", Model.DOB) %></div><br /> <div class="display-label">On Alert</div> <div class="display-field"><%: Html.DisplayFor(Model.OnAlert, "FormBoolean") %></div><br /> <div class="display-label">Deactivated</div> <div class="display-field"><%: Model.Deactivated %></div><br /> </fieldset>
这里是我的FormBoolean显示模板:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Boolean>" %>
<div class="formValueShort"><%= Html.Encode(Model ? "Yes" : "No") %></div>
任何人都可以对此有所了解吗?我也尝试过'LabelFor'(不包括'FormBoolean'),HiddenFor,EditorFor - 都给出了相同的信息。这很奇怪,因为我已经通过我的项目使用过这些东西,所以我不确定它为什么卡在这个特定的项目上。
让我知道是否需要提供更多信息!
啊!很简单!这是漫长的一天!非常感谢。当时间到了的时候,我会将你的回答标记为正确:) – 109221793 2012-01-04 22:20:21