我想从数据库中检索数据并显示在下拉列表中。我使用了模型,所以我也可以从模型中获取。但它没有正确检索。如果在数据库中 4 个条目意味着它显示 4 个下拉按钮,但在下拉列表中没有值。谁能帮我解决这个问题?
我的代码在视图中
<div class="editor-label">
<%: Html.Label("Basic Qualification")%>
</div>
<div class="editor-field">
<div id="basic-qualification-container1" style="margin-bottom:4px;" class="basic-qualification-container left">
<% if (ViewData["BasicQualificationDegrees"]!=null){ %>
<% for (int i=0; i < Model.CandidateQualifications.Count();i++) {%>
<%: Html.DropDownList("BasicQualificationDegree1", new SelectList((IEnumerable<Dial4Jobz.Models.Degree>)ViewData["CandidateBasicQualifications"], "Id", "Name", (IEnumerable<int>)ViewData["BasicQualificationDegrees"]), new { @class = "qualification" })%>
<%: Html.TextBox("BasicQualificationSpecialization1", "", new { @title = "Enter basic qualification degree", @class="specialization" })%>
<%} %>
<%} else { %>
<select id="BasicQualificationDegree1" name="BasicQualificationDegrees"></select>
<%} %>
</div>
<div class="left">
<input type="button" id="btnAddBasicQualification" value="Add" />
<input type="button" id="btnDelBasicQualification" value="Remove" />
</div>
</div>