Back to List Previous Next control in .NET issue
<p>I need help because I didn't find out a solution for a project where I am using MVVM. 
In one hand I have a Default.aspx that contains an UpdatePanel with two user controls. The first control is a FilterControl with some Fields to filter. 
The second control is a GridView that allows pagination and populates data from the database when I press the button search in my FilterControl. Let's say that the query returns 100 records. So if I set the PageSize to 20 results I have 5 pages in my GridView ok?</p>

<p>On the other hand I have a Details page with a FormView that recieves an Id parameter of an item from the GridView and shows the information about it. Just above of asp:FormView code I have another user control that gets the data filtered from the gridview in a Session variable throught the corresponding ViewModel, and calculates which items should be next and previous so I have one "Back to List" link and "Previous" and "Next" links. The previous and next links loads correctly. They are LinkButtons with OnClick event that makes Response.Redirect(PrevLink); for example, where PrevLink is the link where the page redirects ~/details.aspx?Id=5).</p>

<p>I am controlling the navigation asynchronously throughout an eventHandler and HistoryEventArgs so when I press the Back button of the browser everything is fine and I get the desired results in default.aspx page. Whenever a postback is fired in default page, when changing the page index of the gridview, for example, or executing a new query in the filter, I call the AddHistoryPoint of ScriptManager and save several keys and values (Filter fields, Number of page, etc).</p>

<p>The problem comes when I press the Back to List LinkButton. I wish the data were the same as before going to the detail page. I have Response.Redirect("~/default.aspx") in the OnClick event of this button. </p>

<p>Do you have any ideas in how to manage this?</p>

<p>Thank you very much!!</p>

<hr>

<p><strong>Copied code from the answer here</strong></p>

<p>Thank you for the answers. @Guvante I don't want to put the "back to list" on client side because when I Edit the Details page the visible property of the navigation control is set to false. I think I didn't express myself correctly. But I don't have the Response.Redirect in the OnClick event of the aspx page. What I have in the source code of the page is OnClick=lkbBackToList_Navigate.</p>

<p>I have it in the codebehind in this way:</p>

<pre><code>protected void lkbNext_Navigate(object sender, EventArgs e)
{
   Response.Redirect(NavigationViewModel.NextUrl);
}

protected void lkbPrevious_Navigate(object sender, EventArgs e)
{
   Response.Redirect(NavigationViewModel.PreviousUrl);
}

protected void lkbBackToList_Navigate(object sender, EventArgs e)
{
   Response.Redirect(NavigationViewModel.BackToListUrl);
}
@msarchet this is some of my code in default.aspx code behind. When I do postback I save the state of the filters, pageindex and so on in session

public event EventHandler&lt;HistoryEventArgs&gt; CaptureClientBrowsing;

protected void Page_OnInit(EventArgs e) 
{
    this.CaptureClientBrowsing += new EventHandler&lt;HistoryEventArgs&gt;(CaptureClientBrowsing_Event); 
}

protected override void SaveDataInSession() 
{
    SaveInSession("FilterViewModel", this.FilteringControl.ViewModel);
    SaveInSession("PageIndex", this.CurrentPageIndex); //CurrentPageIndex is a property with the page index of the gridview 
}

protected void CaptureClientBrowsing_Event(object sender, HistoryEventArgs e) 
{    LoadDataFromSession(e.State); //e.State is a NameValueCollection with the values stored in session for example FilterViewModel has the user control FilteringControl and "PageIndex" has the page index of the gridview    ControlsDataBinding(); 
}
</code></pre>

<p>The SaveInSession method just keep Session[key] = object where key is a string as it follows: </p>

<pre><code>string key = string.Format("{0}.{1}.{2}", this.GetType(), nameValue, index); 
</code></pre>

<p>an example of key is </p>

<pre><code>"ASP.customers_default_aspx.PageIndex.1"` so `Session[key]=1
</code></pre>

<p>If I click in other page (for example the page number 6) of the grid view the value of the key variable would be</p>

<pre><code>"ASP.customers_default_aspx.PageIndex.2"` and `Session[key]=5
</code></pre>

<p>Here is where I am stuck. If I browse from the details page to default page clicking back in the browser the <code>CaptureClientBrowsing_Event</code> fires and the controls are loaded correctly and also the values of the filter.</p>

<p>What I want is that when I click the LinkButton "Back to List" the controls and the filter get loaded too. How do I get the NameValueCollection if I don't have the history args? If I click three times to next and then click to Bak to list how do I know the Session values to load?</p>

<p>Maybe there are a lot of questions and this is hard to handle but I've tried to be the most specific I could.</p>
