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

Posted on 2007-08-10
Last Modified: 2013-12-24
I have a simple gridview in 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.
Question by:carled
    LVL 39

    Accepted 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.

    Expert Comment

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    If you're not part of the solution, you're part of the problem.   Tips on how to secure IoT devices, even the dumbest ones, so they can't be used as part of a DDoS botnet.  Use PRTG Network Monitor as one of the building blocks, to detect unusual…
    ADCs have gained traction within the last decade, largely due to increased demand for legacy load balancing appliances to handle more advanced application delivery requirements and improve application performance.
    After creating this article (, I decided to make a video (no audio) to show you how to configure the routers and run some trace routes and pings between the 7 sites…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now