Datagrid Imagebutton Delete Problem

E

Erik Lautier

Hi, I'm running into a bit of a headache trying to use an imagebutton
in my datagrid; if I use a linkbutton in a buttoncolumn, it all works
perfectly, but the second I switch to an imagebutton in a
templatecolumn, nothing happens...I don't get an error, it's just that
the row is not deleted. Relevant code is below; would really
appreciate a helping hand. Thanks.

<asp:DataGrid ID="dgCart" AutoGenerateColumns="false"
ondeletecommand="Delete_Item" runat="server">
<columns>
<asp:BoundColumn DataField="ID"/>
<ASP:TEMPLATECOLUMN>
<ITEMTEMPLATE>
<ASP:IMAGEBUTTON id="ImageDelete" Runat="server"
AlternateText="Delete" ImageUrl="buttons/delete.gif"
CommandName="Delete">
</ASP:IMAGEBUTTON>
</ITEMTEMPLATE>
</ASP:TEMPLATECOLUMN>
</columns>
</asp:DataGrid>


Sub Delete_Item(s As Object, e As DataGridCommandEventArgs)
objDT = Session("Cart")
objDT.Rows(e.Item.ItemIndex).Delete()
Session("Cart") = objDT

dgCart.DataSource = objDT
dgCart.DataBind()
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top