2016-11-21 35 views
0

我正在使用按鈕單擊事件將數據綁定到gridview並使用templatefield修改其中一列以使其可點擊,但是當我在頁面加載上綁定gridview時,它顯示數據我可以點擊需要點擊的數據,但是當點擊數據時會出現問題。它說這個錯誤:在頁面加載時綁定gridview時出錯

Invalid postback or callback argument. Event validation is enabled using in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.

我不知道發生了什麼在這裏,因爲它是用一個按鈕來觸發GridView的

+0

您必須顯示您的代碼,否則我們無法修復它。但是你應該在'GridView'的'RowCreated'中用'Page.ClientScript.GetPostBackClientHyperlink'在你的'GridViewRow.Cell'上註冊客戶端事件。 –

+0

如何使用Page.ClientScript.GetPostBackClientHyperlink進行註冊? –

+0

編輯你的問題,包括你的代碼,然後我們可以幫助解決它。不過,我在這裏提供了一個示例:http://stackoverflow.com/a/6250846/284240 –

回答

0

我現在固定它,當工作的罰款。我只需創建一個名爲BindGridview()的新方法,然後使用if(!IsPostBack)來調用該方法,並且它現在可以正常工作:D