In this post, i will explain how to get gridview control defined in one page into another page. This is accomplished with "Page.PreviousPage" property.
Let Page1.aspx contains a gridview control and we want this gridview (or any object) be passed to another page called page2.aspx.
We try this goal in two alternatives ways:
- Button with PostBackUrl="Page2.aspx" attribute.
- Server.Transfer("Page2.aspx", true); by coding.
In page1.aspx define:
- Gridview control named - grid
- Button with postbackUrl="page2.aspx" - btn1
- and another Button with click-event - btn2
In Page2.aspx define:
Form control (default markup added by VS)
Now Open the Page1.aspx from browser (or, run from VisualStudio).
Using the above technique and custom public properties, we can access any object from page1 to page2.