我的控制器代码
public ActionResult Create(string id)
{
ViewBag.ALLO_ID = new SelectList(_unitOfWork.AllocationMRepository.Get(), "ALLO_ID", "ALLO_ID", id);
ViewBag.TERR_ID = new SelectList(_unitOfWork.TerrListRepository.Get().OrderBy(m => m.TERR_ID), "TERR_ID", "TERR_ID");
ViewBag.ITEM_ID = new SelectList(_unitOfWork.SampleInfo.Get(), "ITEM_ID", "ITEM_ID");
return View();
}
在我看来
<div class="editor-field">
@Html.DropDownList("ALLO_ID", String.Empty)
@Html.ValidationMessageFor(model => model.ALLO_ID)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.TERR_ID, "Territory Name")
</div>
<div class="editor-field">
@Html.DropDownList("TERR_ID", String.Empty)
@Html.ValidationMessageFor(model => model.TERR_ID)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.ITEM_ID, "Item Name")
</div>
<div class="editor-field">
@Html.DropDownList("ITEM_ID", String.Empty)
@Html.ValidationMessageFor(model => model.ITEM_ID)
</div>
这些下拉列表是如何创建的?这对我来说不是很清楚。我想知道它是如何工作的。这可能是一个胡说八道的问题,但我很想知道,因为我是初学者。
先谢谢了。