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.
LVL 1
carledAsked:
Who is Participating?
 
appariCommented:
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.
0
 
DinoBoYCommented:
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.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.