【发布时间】:2013-12-18 16:02:57
【问题描述】:
如何将 ViewBag 传递/发送到我的 DisplayTemplates?我不能为此使用 ViewModel,所以我认为 ViewBags ...... 例如:
我的部分观点:
@Html.DisplayFor(model => model.Car)
Car.cshtml(显示模板):
<tr>
<td>
@Html.TextBoxFor(model => model.Name, new { Name = modelFieldInitialName + "Name", id = modelFieldInitialId + "Name" })
@Html.ValidationMessageFor(model => model.Name)
</td>
<td>
@Html.DropDownListFor(model => model.Brand, new SelectList(ViewBag.Brands, "Description", "Description"), "", new { Name = modelFieldInitialName + "Brand", id = modelFieldInitialId + "Brand" })
@Html.ValidationMessageFor(model => model.Brand)
</td>
</tr>
【问题讨论】:
标签: html asp.net asp.net-mvc-4 razor viewbag