I have an Ajax button that whenever I click it, it shows a single record from the database (in my Controller I used .Take(1) )
Here is my view :
<script src="~/Scripts/jquery-3.1.1.min.js"></script>
<script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>
<script type="text/javascript" language="javascript">
function ClearResults() {
$("#current").empty();
}
</script>
<div class="row">
<div class="column">
<h2 class="header-text">CURRENT</h2>
<div class="current" id="current">
X000
</div>
</div>
</div>
<div class="row">
@Ajax.ActionLink(" ", "BtnNext", null, new AjaxOptions
{
HttpMethod = "GET",
InsertionMode = InsertionMode.Replace,
UpdateTargetId = "current",
LoadingElementId = "loading",
OnBegin = "ClearResults",
}, new { @class = "Middle-next dim btn btn-large-dim", @id = "Link1"})
</div>
Here is my controller for the button :
public PartialViewResult BtnNext(int count = 0)
{
System.Threading.Thread.Sleep(1000);
var model = db.Queues.OrderBy(x => x.QueueNumber).Take(1);
return PartialView("_queuenumber", model);
}
What I would like to do here is - whenever I click the next button it will display the first record from the database, then when I click it again it will show the second record and so on..
(as of now it only show the first data from database)
I wonder if that is even possible and what kind of stuff should I use to do that?