@{
foreach (CaseCount cc in @Model.CaseCounts)
{
<tr>
<td>@cc.Country</td>
<td>@string.Format("{0:n0}", cc.RegisteredCases)</td>
<td>@Html.DropDownList("Reports", new SelectList(@Model.ReportList, "Value", "Text"), new { onchange = "window.location.href='Reports/RenderReport/' + this.value + '/' + @cc.Country;" })</td>
</tr>
}
}
@ cc.Country无法识别。控制器中的操作未被触发:(
如果我删除@ cc.Country或只是将其硬编码,则可以正常工作
答案 0 :(得分:2)
问题在于你将@ cc.Country作为文本放在引号内。试试这个:
<td>@Html.DropDownList("Reports", new SelectList(@Model.ReportList, "Value", "Text"), new { onchange = "window.location.href='Reports/RenderReport/' + this.value + '/'" + cc.Country + ";" })</td>