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
- public IActionResult Create()
- {
- var results = _context.GetAll().OrderBy(Employee => Employee.EmployeeId).LastOrDefault();
- return View();
- }
- [HttpPost]
- [ValidateAntiForgeryToken]
- public async Task
Create(Employee employee) - {
- }
on view create
- class="title_of_div">
- style="display: inline">Last
- class="row">class="col-md-4">
- >
"ModelOnly" class="text-danger">class="form-group">- ="EmployeeId" class="control-label">
- for="EmployeeId" class="form-control" />
- for="EmployeeId" class="text-danger">
class="form-group">- ="EmployeeName" class="control-label">
- for="EmployeeName" class="form-control" />
- for="EmployeeName" class="text-danger">
class="form-group">- ="EmployeeAge" class="control-label">
- for="EmployeeAge" class="form-control" />
- for="EmployeeAge" class="text-danger">
class="form-group">- "submit" value="Create" class="btn btn-default" />

Jenith ThakkarRank #789 · 2.9K reputationPosted Jan 6, 2019, 10:12 PM EST
ahmed elbarbaryRank #1,060 · 1.8K reputationPosted Jan 7, 2019, 12:17 AM EST
Jenith ThakkarRank #789 · 2.9K reputationPosted Jan 7, 2019, 1:08 AM EST