ViewBag 值未显示在 select 框中?
ViewBag values are not displaying in a select box?
ViewBag 中的值列表,并希望在 select 框中显示 这些值.The values are coming inside of the view.But it isn't displaying 。
代码块:
<select name="postoffice">
<option>-select-</option>
@if (ViewBag.s != null)
{
foreach (var f in ViewBag.s)
{
<option value="@f.po">@f.po</option>
}
}
</select>
在执行 foreach 循环(列表)之前,您需要以特定格式转换 ViewBag.s ViewBag.s
ViewBag 中的值列表,并希望在 select 框中显示 这些值.The values are coming inside of the view.But it isn't displaying 。 代码块:
<select name="postoffice">
<option>-select-</option>
@if (ViewBag.s != null)
{
foreach (var f in ViewBag.s)
{
<option value="@f.po">@f.po</option>
}
}
</select>
在执行 foreach 循环(列表)之前,您需要以特定格式转换 ViewBag.s ViewBag.s