[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1017
  • Last Modified:

Remembering page number in paging gridview on return after editing on separate page?

I have a simple gridview in asp.net 2.0 (using VB) and, as the row has too many fields to show/edit in the gridview, I have created a hyperlink field using the row's index property to go to a separate page to edit all the row's fields. I then allow the user to change details and update the record. At this point I do a "server.transfer" back to the gridview list page, but of course it returns right back to the beginning of the list again, rather than remembering the point I'd paged through to... is there any way of "remembering" the page number I was on so I can go back to the same point on my return to this page?

I've tried programatically setting one of the hyperlinkfields to "gridview1.pageIndex" so I can pass that back in the url string on return but it fails with some kind of object reference as (I think) I'm not setting the field to a field from the database query.
1 Solution
you can do it as follows,

save current position to a session variable or a hidden field in the child form. after saving when you want to go back to parent form, if you are saving the current position in session get the previous position from session and go to that position. if you are using hidden variable you can pass back the value using querystring and in the parent form read the query string value.
But you can instead use GridView with FormView on the same page. That is, instead of opening new page, you can bind FormView with specified ID (taken form GridView). After you have saved the record you can switch back to GridView. PageIndex and other GridView properties stay intact.

Featured Post

Transaction-level recovery for Oracle database

Veeam Explore for Oracle delivers low RTOs and RPOs with agentless transaction log backup and transaction-level recovery of Oracle databases. You can restore the database to a precise point in time, even to a specific transaction.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now