2014-06-17 35 views
0
@{ 
      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不被识别。在控制器的动作不会被触发:(剃须刀onchange不承认@variable

如果我删除@ cc.Country或者干脆把它硬编码,它的工作原理

+0

你能请张贴渲染HTML – rhughes

回答

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> 
+1

这帮助,但最终的正确的路线是:​​@ Html.DropDownList( “报告”,新的SelectList(@ Model.ReportList“ Value“,”Text“),new {onchange =”window.location.href ='Reports/RenderReport /'+ this.value +'/“+ @ cc.Country +”';“}) –