ViewData.ModelMetadata.Properties
@foreach (var property in ViewData.ModelMetadata.Properties
.Where(p => (p.AdditionalValues.Count > 0) && ((bool)p.AdditionalValues["tags"])))
{
// Generate form here
}
我能够显示
LabelFor
正确使用
@Html.LabelFor(model => Model,
property.DisplayName,
htmlAttributes: new { @class = "control-label col-md-2" })
但我似乎无法让编辑工作。
我试过了
@Html.HiddenFor(model => model.GetType().GetProperties().First(t=>t.Name == property.PropertyName))
模板只能用于字段访问、属性访问、一维数组索引或单参数自定义索引器表达式。
我也试过了
@Html.HiddenFor(model => property)
null
可以这样做吗,或者我需要手动编码每个输入?