Click here to Skip to main content
11,813,557 members (46,935 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: MVC DataGrid
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 at 31-Dec-12 0:35am
is it k nw???
sorry i m new to this blog..
Karthik. A at 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 at 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 at 29-Dec-12 20:43pm
Karthik. A at 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
0 Abhinav S 275
1 Palash Mondal_ 190
2 KrunalRohit 150
4 Manas_Kumar 115
0 OriginalGriff 3,877
1 KrunalRohit 2,526
2 Maciej Los 2,245
3 CPallini 2,240
4 ppolymorphe 1,750

Advertise | Privacy | Mobile
Web03 | 2.8.151002.1 | Last Updated 30 Dec 2012
Copyright © CodeProject, 1999-2015
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