Solution
The RedirectToAction function in ASP.NET MVC is used to redirect to a different controller or another action inside the same controller. Use the RedirectToAction method in your controller to send users from a "Edit" page back to the "Index" page.
Make sure that you do not mix the concept of page number with ID. However, you can do that but you need to track the page number (say in a ViewBag or a proper ViewModel with appropriate properties) OR use some complex logic to find the page with items and then send that to the Index view with the proper overloaded signature.
Or just use a pagination object:
public class Pagination { public int PageNumber { get; set; } = 1; public int PageSize{ get; set; } = 10; public int TotalItems{ get; set; } public bool SortDirection{ get; set; } = SortDirection.Ascending; } public enum SortDirection { Ascending, Descending } |
then redirect
return RedirectToAction("Index", new Pagination() { PageSize = pageSize, PageNumber = pageNumber }); |
to something like:
public IActionResult Index(PaginationObject paginationObject) { // rest here to returned the list of page items } |
Answered by: >Mark Schultheiss
Credit: >StackOverflow
Suggested Blogs
>Creating a pivot table by 6 month interval rather than year
>How remove residual lines after merge two regions using Geopandas in python?
>How to mock a constant value in Python?
>Can I call an API to find out the random seed in Python `hash()` function?
>How to configure python in jmeter?
>How to fix routes in Laravel?