问题
You see my dilemma here. It's with the binding x => property.Name. So normally you would do something like x=> x.someproperty. But I'm using reflection so I can't do it that way. I tried a number of things. Using the viewdata to find the property. Doesn't like that. Any thoughts on the matter?
foreach (var property in Model.GetType().GetProperties())
{
<div class="row">
<div class="col-md-2">
<label>@(property.Name ?? property.Name)</label>
</div>
<div class="col-md-2">
@Html.TextBoxFor(x => property.Name, new { @id = property.Name})
</div>
</div>
}
来源:https://stackoverflow.com/questions/32282863/asp-net-mvc-model-binding-with-reflection