【问题标题】:How to call ActionResult to get Data again in MVC如何在 MVC 中调用 ActionResult 再次获取数据
【发布时间】:2015-02-10 21:22:48
【问题描述】:
public ActionResult Countries(int id=0, int from=0)

我的控制器和返回 Country 的 ActionResult。

现在:

  @foreach (var item in Model.Matches)
{   
    <tr>
        <td>                
              @Html.DisplayFor(modelItem => item.Description)     
        </td>
    </tr>

}

我的观点,我如何说 From += 10 并让 ID 与它现在打开的页面中的 ID 保持相同,并且从 DB 中再取 10 个国家?

@Html.ActionLink("next", "Countries", Model.From += 10) 

这没用

【问题讨论】:

  • 你必须扩展你的模型并使用 Html.HiddenFor() 在你的视图中添加一个隐藏字段。
  • 你能解释一下,或者给我一个教程吗?

标签: c# html model-view-controller


【解决方案1】:

您可以编写一个内联 javascript 来执行此操作。

 @Html.ActionLink("next", "Countries", parseInt(Model.From)+10) 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-28
    • 1970-01-01
    • 2021-09-15
    • 1970-01-01
    相关资源
    最近更新 更多