I have a problem with Cross-Page Posting a GridView.
The error I’m getting is the following:
Object reference not set to an instance of an object.
Steps I took:
- Create the new Page and add a GridView
-
Create a button with PostBack to the new page.
<asp:Button ID="Button1" Text="Button 1" PostBackUrl="~/Page2.aspx?button=1" runat="server" /> -
Adding code behind to the new Page.
protected void Page_Load(object sender, EventArgs e) { if (Page.PreviousPage == null) { Label1.Text = "Vul een planing in."; } else { ContentPlaceHolder pageContent = (ContentPlaceHolder)(Page.PreviousPage.FindControl("Content1")); GridView1.DataSource = pageContent.FindControl("GridView2"); // In this line I'm getting the error } }
Looking at the error I forgot a reference. Thnx for the help:)
Please check followinf link to fetch previous page control value in another page, so you can use same login in your code, but if the griview contains large amount of data your page performance will get reduced.
http://www.allinterview.com/showanswers/36626/page4.html