跨頁發佈GridView遇到問題。跨頁發佈GridView
我得到的錯誤如下: 未將對象引用設置爲對象的實例。
步驟我把:
- 創建新頁面,並添加一個GridView
創建回發一個按鈕,新的一頁。
<asp:Button ID="Button1" Text="Button 1" PostBackUrl="~/Page2.aspx?button=1" runat="server" />
將代碼添加到新頁面的後面。
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 } }
望着錯誤我忘了參考。 thnx的幫助:)