Click here to Skip to main content
13,150,622 members (43,657 online)
Rate this:
Please Sign up or sign in to vote.
See more:
Hello All,
I have a datagrid in my mvc application, i got paging to it.
my real problem is when i am on 5th page(or any other page) and delete a record(row) then its getting me redirect to 1st page instead of keeping on that page itself.
i am trying to get the page number from where the record is deleted but i am unsuccessful in that,
can any one help me how to get the page number of grid or some how from some other way to solve my problem.
Posted 28-Dec-12 17:26pm
salah9 31-Dec-12 0:35am
is it k nw???
sorry i m new to this blog..
Karthik. A 31-Dec-12 0:43am
No worries! This is fine too, if you have comments about an answer you have to comment against that. You will get used to all these stuff as you get acquainted w/ CodeProject! Welcome by the way!!!
salah9 31-Dec-12 0:46am
thanks.. : )

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

That's because, you are not passing any data to your delete method that could enable it to redirect to the appropriate page. Following sample gives you an idea...

Delete method

public ActionResult Delete(int itemId, int pageNo)
   // delete the item using itemId
   // redirect to grid page by passing the page no. too
   return RedirectToAction("Index", "Home", new { pageNumber = pageNo });

While rendering the delete link also include the page number in the link generated, i.e., your view model should also contain the current page number. So instead of:



Abhishek Pant 29-Dec-12 20:43pm
Karthik. A 31-Dec-12 0:09am
Thanks !

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web01 | 2.8.170924.2 | Last Updated 30 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100