【发布时间】:2020-12-25 15:36:49
【问题描述】:
我试图在 razor 视图中实现一个下拉列表,其中包含来自 for 循环的项目。 我需要 html 结果看起来像
<select name="budget">
<option>--Please select --</option>
<option>Not sure</option>
<option> 1000 - 2000</option>
<option> ...</option>
<option>above 11000</option>
我的代码如下所示:
<select name = "budget" >
<option>--Please select --</option>
<option>Not sure</option>
@for (int j = 1000; j < 11000; j += 1000)
{
<option>
@{
("{{0}} -{{1}}", j, j + 1000);
}
</option>
}
<option>above 11000</option>
</select>
我得到的错误是:"Only assignment, call, increment, decrement, await, and new object expressions can be used as a statement
提前致谢
【问题讨论】:
标签: c# asp.net-core-mvc razor-pages