Reputation: 11
i have a linked button in my a datalist with value of datatype int onclick it is supposed to display all details in a datalist list on another page based on the id link button chosen.
But i am having this error in my codes:
An exception of type 'System.InvalidCastException' occurred in App_Web_m5vpwb3j.dll but was not handled in user code
Additional information: Unable to cast object of type 'System.Web.UI.WebControls.LinkButton' to type 'System.Web.UI.WebControls.Button')
Upvotes: 0
Views: 899
Reputation: 388123
Both a LinkButton
and a Button
are a subclass of WebControl
. However, they are siblings in the type hierarchy, so you cannot cast one into the other. They are not compatible to each other.
So what you are doing simply doesn’t work, you will have to look for another way to achieve what you want to achieve.
Upvotes: 2