In this article I will explain with an example, how to access Previous Page controls in ASP.Net using C# and VB.Net.
Previous Page controls can be accessed on Current Page using the Cross Page PostBack technique in ASP.Net.
Cross Page Posting (CrossPagePostBack) is a way to submit one page to another page and it also allows to access controls of Previous Page using the PreviousPage property.
There are two ways of doing CrossPagePostBack
1. By setting PostBackUrl property of ASP.Net Button, LinkButton and ImageButton
2. By using Server.Transfer
Database
Here I am making use of Microsoft’s Northwind Database. The download and install instructions are provided in the following article.
HTML Markup
I have added an ASP.Net GridView and (two buttons that will be used to redirect to the other page) onto my page as shown below.
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" Font-Names="Arial"
Font-Size="11pt" AlternatingRowStyle-BackColor="#C2D69B" HeaderStyle-BackColor="green">
<Columns>
    <asp:BoundField ItemStyle-Width="150px" DataField="CustomerID" HeaderText="CustomerID" />
    <asp:BoundField ItemStyle-Width="150px" DataField="City" HeaderText="City" />
    <asp:BoundField ItemStyle-Width="150px" DataField="Country" HeaderText="Country" />
    <asp:BoundField ItemStyle-Width="150px" DataField="PostalCode" HeaderText="PostalCode" />
</Columns>
<AlternatingRowStyle BackColor="#C2D69B" />
</asp:GridView>
<asp:Button ID="Button1" runat="server" Text="Button1" PostBackUrl = "~/Page2.aspx" />
<asp:Button ID="Button2" runat="server" Text="Button2" OnClick = "Redirect" />

Namespaces
You will need to import the following namespaces.
C#
using System.Data;
using System.Configuration;
using System.Data.SqlClient;
 
VB.Net
Imports System.Data
Imports System.Configuration
Imports System.Data.SqlClient
 
 
Populating the GridView with records from
The GridView is populated with records from the Customers Table of the Northwind database inside the Page load event.
C#
protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        this.BindGrid();
    }
}
 
private void BindGrid()
{
    string constr = ConfigurationManager.ConnectionStrings["conString"].ConnectionString;
    using (SqlConnection con = new SqlConnection(constr))
    {
        using (SqlCommand cmd = new SqlCommand())
        {
            cmd.Connection = con;
            cmd.CommandText = "select top 10 * from customers";
            using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
            {
                DataTable dt = new DataTable();
                sda.Fill(dt);
                GridView1.DataSource = dt;
                GridView1.DataBind();
            }
        }
    }
}
 
VB.Net
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
    If Not IsPostBack Then
        Me.BindGrid()
    End If
End Sub
 
Private Sub BindGrid()
    Dim constr As String = ConfigurationManager.ConnectionStrings("conString").ConnectionString
    Using con As New SqlConnection(constr)
        Using cmd As New SqlCommand()
            cmd.Connection = con
            cmd.CommandText = "select top 10 * from customers"
            Using sda As New SqlDataAdapter(cmd)
                Dim dt As New DataTable()
                sda.Fill(dt)
                GridView1.DataSource = dt
                GridView1.DataBind()
            End Using
        End Using
    End Using
End Sub

Redirecting to Other page using CrossPagePostBack
In order to perform CrossPagePostBack, Button1 has been set with PostBackUrl while Button2 uses Server.Transfer method.
C#
protected void Redirect(object sender, EventArgs e)
{
    Server.Transfer("~/Page2.aspx");
}

VB.Net
Protected Sub Redirect(ByVal sender As Object, ByVal e As EventArgs)
   Server.Transfer("~/Page2.aspx")
End Sub

Handling the CrossPagePostBack and referencing the Control
On the destination page, the previous page’s reference is available in the Page.PreviousPage property. The control i.e. GridView can be easily accessed using the FindControl method.
C#
protected void Page_Load(object sender, EventArgs e)
{
    if (this.Page.PreviousPage != null)
    {
        GridView GridView1 = (GridView)this.Page.PreviousPage.FindControl("GridView1");
    }
}

VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        If (Not (Me.Page.PreviousPage) Is Nothing) Then
            Dim GridView1 As GridView = CType(Me.Page.PreviousPage.FindControl("GridView1"), GridView)
        End If
End Sub


Accessing Previous Page when using Master Pages
Now when Master Pages are being used, first the reference of ContentPlaceHolder is determined and then control i.e. GridView can be easily accessed using the FindControl method.
C# 
protected void Page_Load(object sender, EventArgs e)
{
    if (this.Page.PreviousPage != null)
    {
        Control ContentPlaceHolder1 = this.Page.PreviousPage.Master.FindControl("ContentPlaceHolder1");
        GridView GridView1 = (GridView)ContentPlaceHolder1.FindControl("GridView1");
    }
}

VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        If (Not (Me.Page.PreviousPage) Is Nothing) Then
            Dim ContentPlaceHolder1 As Control = Me.Page.PreviousPage.Master.FindControl("ContentPlaceHolder1")
            Dim GridView1 As GridView = CType(ContentPlaceHolder1.FindControl("GridView1"), GridView)
        End If
End Sub
 
Downloads

Download Code