나는 다음과 같이 그 모델 인보이스 페이지에 2 드롭 다운을 갖고 싶어 첫 번째 드롭 다운의 이름으로, 해당 멤버의 주소 만 채워야합니다.EF 여러 드롭 다운
public ActionResult Create()
{
ViewBag.MemberID = new SelectList(db.Members, "MemberID", "FirstName");
return View();
}
와 cshtml 파일은 다음과 같습니다 다음 InvoiceController의 생성() 메소드 코드는 사전에
@model MvcDemoApp.Models.Invoice
@{
ViewBag.Title = "Create";
}
<h2>Create</h2>
@using (Html.BeginForm()) {
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<fieldset>
<legend>Invoice</legend>
<div class="editor-label">
@Html.LabelFor(model => model.MemberID, "Member")
</div>
<div class="editor-field">
@Html.DropDownList("MemberID", String.Empty)
@Html.ValidationMessageFor(model => model.MemberID)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.AddressID)
</div>
<div class="editor-field">
@@Html.EditorFor(model => model.AddressID)@
@Html.ValidationMessageFor(model => model.AddressID)
</div>
<p>
<input type="submit" value="Create" />
</p>
</fieldset>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
감사합니다.
어디에서 여러 번 드롭 다운이 발생합니까? 두 번째 드롭 다운에서 주소를 입력해야하는 위치는 어디입니까? 주어진 코드를 근거로 오해의 소지가 있습니다. –