【发布时间】:2014-05-13 14:25:36
【问题描述】:
查看
...Some Codes...
<select class="form-control" style = "width:400px">
<option selected> select issue type </option>
@foreach( var item in Model._issueList)
{
<option>@item.issueName</option>
}
</select>
...Some Codes...
我的下拉菜单的输出
下拉菜单:issue_one、issue_two、issue_three
现在我想在我的下拉列表中选择我的 issue_three 并将其保存在 Viewbag.select 中,希望应该是正确的代码,以便我可以传输 issue_three 到我的 Viewbag.select
测试
...foreach code...
Viewbag.select = ????
【问题讨论】:
-
不清楚你在问什么。代码去哪里?为什么不使用 Html.DropdownList 帮助器?
-
@Paddy,因为我还在努力学习如何使用 Html.DropdownList,所以我还在学习 ASP.net 抱歉。
-
我的下拉列表已经开始工作了,例如,在我的下拉列表中有三个选项 issue_one, issue_two, issue_three。那么如果我在我的下拉列表中选择 issue_three 我希望它在 Viewbag.select 中传输,以便我可以在我的 href ="Home 中使用它/Variable?value=@Viewbag.select".
-
抱歉,我不明白您希望这种“转移”发生在哪里 - 在控制器中?
-
在我看来,我想使用从下拉列表中选择的选项。将其用作 @Viewbag.select
标签: asp.net razor foreach viewbag