table of Contents
First get List
In obtaining written inside Controller List, and then spread through the view ViewBag
ViewBag.testList = _testBll.GettestList();
So get to the List collection
View deal
First of all, what is received
@{
var testList = ViewBag.testList;
}
Then, write an HTML tag, use select tag, value is the id, shows the 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>