0

我有这个 Ajax.ActionLink 按钮

@Ajax.ActionLink(" ", "BtnNext", null, new AjaxOptions
                            {
                            HttpMethod = "GET",
                            InsertionMode = InsertionMode.Replace,
                            UpdateTargetId = "current"
                            }, new { @class = "Middle-next dim btn btn-large-dim", @id = "Link1"})

这是控制器:

    public PartialViewResult BtnNext()
    {
        List<Queue> model = db.Queues.ToList();
        return PartialView("_queuenumber", model);
    }

基本上,当我单击 Ajax 按钮时,它会显示我的数据库中的整个表数据,
我想要做的是每当我单击此按钮时,它会显示我的数据库中的第一个数据,当我再次单击它时,会显示第二个数据.. 和很快。那可能吗?谢谢你。

4

1 回答 1

0

在 Action Link 中添加参数 count,count = -1 init:

x.ActionLink(" ", "BtnNext", new { count= count + 1, new AjaxOptions
                            {
                            HttpMethod = "GET",
                            InsertionMode = InsertionMode.Replace,
                            UpdateTargetId = "current"
                            }, new { @class = "Middle-next dim btn btn-large-dim", @id = "Link1"})

在控制器中

 public PartialViewResult BtnNext(int count = 0)
        {
            //retrive record with order count
model = GetRecordWithOrder(count);
            return PartialView("_queuenumber", model);
        }
于 2019-03-13T06:45:43.377 回答