【发布时间】:2017-03-14 16:27:11
【问题描述】:
如何从视图内的下拉列表控件中检索selectedValue(不在模型中存储任何值)?
在 Razor 部分有什么办法吗?
我的代码:
<script type="text/javascript">
function dada(aa) {
return document.getElementById(aa).value;
}
</script>
@using (Html.BeginForm("MonetaryTransactions", "Trading"))
{
IEnumerable<Mt4Transaction> results = from result in Model
select result;
// This is the dropDown control which I need to get the selectedValue from ...
@Html.DropDownList("TransactionType",
new SelectList(Enum.GetValues(typeof(Forex.Reports.ReportValueType))),
"Transaction Type",
new { @class = "form-control", @id = "aa" });
switch ("???")
{
case "Withdrawal":
{
results =
from result in Model
where result.Profit > 0
select result;
}
break;
case "Deposit":
{
results =
from result in Model
where result.Profit < 0
select result;
}
break;
case "UnidentifiedProfit":
{
results =
from result in Model
select result;
}
break;
}
【问题讨论】:
标签: .net asp.net-mvc razor html.dropdownlistfor