Reputation: 33
I am casting one Image Button to a Link Button. But I'm getting the error: "Unable to Cast object of type Image Button to type LinkButton."
I am stuck, please guys help me out.
My Code :
LinkButton lnkbtnresult = (LinkButton)e.Row.FindControl("Imgresult");
Upvotes: 1
Views: 3672
Reputation: 148150
Use ImageButton
instead of LinkButton
as you can not cast ImageButton
to LinkButton
ImageButton imgbtnresult = (ImageButton)e.Row.FindControl("Imgresult");
Once you have ImageButton, you can use its properties to assign to LinkButton object if really required.
LinkButton lnkButton = new LinkButton();
lnkButton.SomeProperty = imgbtnresult.SomeProperty;
Upvotes: 1