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 ThakkarPosted Jan 7, 2019, 6:08 AM
ahmed elbarbaryPosted Jan 7, 2019, 5:17 AM
Jenith ThakkarPosted Jan 7, 2019, 3:12 AM