2014-06-30 51 views
1

我將一個圖像按鈕投射到鏈接按鈕。但是我得到錯誤:「無法投入類型圖像按鈕的對象鍵入LinkBut​​ton。」無法將類型爲'System.Web.UI.WebControls.ImageButton'的對象轉換爲鍵入'System.Web.UI.WebControls.LinkBut​​ton'

我被卡住了,請大家幫幫我。

我的代碼:

LinkButton lnkbtnresult = (LinkButton)e.Row.FindControl("Imgresult"); 
+0

只是爲了知道爲什麼要將圖像按鈕鏈接到按鈕,而不是ImageButton本身? –

+0

@KiranHegde它只是爲我的個人信息。 – Vishnu

回答

1

使用ImageButton而不是LinkButton,你可以不投ImageButtonLinkButton

ImageButton imgbtnresult = (ImageButton)e.Row.FindControl("Imgresult"); 

一旦你的ImageButton,你可以使用它的屬性分配到LinkBut​​ton的對象,如果真的需要。

LinkButton lnkButton = new LinkButton(); 
lnkButton.SomeProperty = imgbtnresult.SomeProperty; 
相關問題