在Controller里面写好获取List,然后通过ViewBag传到视图
ViewBag.testList = _testBll.GettestList();
这样获取到了List集合
首先,接收一下
@{
var testList = ViewBag.testList;
}
然后,写一个HTML标签,使用select标签,value是id,显示的是name
<th>测试下拉框</th>
<td data-title="测试下拉框">
<select id="test" name="test" style="width: 150px; height: 23px;">
@foreach (test item in testList)
{
<option selected="selected" value="@item.id">@item.Name</option>
}
</select>
</td>
原文:https://www.cnblogs.com/yunquan/p/10968974.html