problem
How to pass value of last record from controller to view when click on last button .
I have controller employee have action create
In this action create I have view for create action
on view create i have button Last
this button when i press on it i need it get last record
if table employee have employeeid from 1 to 5 and click on last button it must go to record 5 and show it
so that what i do as below
Code:public IActionResult Create() { var results = _context.GetAll().OrderBy(Employee => Employee.EmployeeId).LastOrDefault(); return View(); } [HttpPost] [ValidateAntiForgeryToken] public async Task<IActionResult> Create(Employee employee) { } on view create <div class="title_of_div"> <button id="BtnLast" style="display: inline"><b>Last</b></button> </div> <div class="row"> <div class="col-md-4"> <form asp-action="Create"> <div asp-validation-summary="ModelOnly" class="text-danger"></div> <div class="form-group"> <label asp-for="EmployeeId" class="control-label"></label> <input asp-for="EmployeeId" class="form-control" /> <span asp-validation-for="EmployeeId" class="text-danger"></span> </div> <div class="form-group"> <label asp-for="EmployeeName" class="control-label"></label> <input asp-for="EmployeeName" class="form-control" /> <span asp-validation-for="EmployeeName" class="text-danger"></span> </div> <div class="form-group"> <label asp-for="EmployeeAge" class="control-label"></label> <input asp-for="EmployeeAge" class="form-control" /> <span asp-validation-for="EmployeeAge" class="text-danger"></span> </div> <div class="form-group"> <input type="submit" value="Create" class="btn btn-default" /> </div> </form> </div> </div>




Reply With Quote
