Logo 
Search:

Asp.net Answers

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds
  Question Asked By: Almas Akhtar   on Mar 20 In Asp.net Category.

  
Question Answered By: Robin Hayes   on Mar 20

I changed the code  (below ) but get this error:



ERROR:

Exception Details: System.InvalidCastException: Specified cast is not valid.

Source Error:


Line 51: Case ListItemType.Item, ListItemType.AlternatingItem, ListItemType.EditItem
Line 52: Dim myDeleteButton As LinkButton
Line 53: myDeleteButton = e.Item.FindControl("btnDelete")




Code <HTML>

<asp:TemplateColumn>

<ItemTemplate>

<asp:LinkButton runat="server" ID="btnDelete" Text="Delete" CommandName="Delete" CausesValidation="false"></asp:LinkButton>

</ItemTemplate>

</asp:TemplateColumn>



</HTML>



<CodeBehind>

Select Case e.Item.ItemType

Case ListItemType.Item, ListItemType.AlternatingItem, ListItemType.EditItem

Dim myDeleteButton As LinkButton

myDeleteButton = e.Item.FindControl("btnDelete")

myDeleteButton.Attributes.Add("onclick", "return confirm('Are you sure you want to delete  this company?');")

End Select

</codebehind>

Can you see what dummy mistake I am making now?



Share: 

 

This Question has 4 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Confirm delete on a Link button Or get search suggestion and latest updates.


Tagged: