PC Review
Forums
Newsgroups
Microsoft DotNet
Microsoft VB .NET
DataList.DeleteCommand event is not getting fired
Forums
Newsgroups
Microsoft DotNet
Microsoft VB .NET
DataList.DeleteCommand event is not getting fired
![]() |
DataList.DeleteCommand event is not getting fired |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
I have a DataList that has an Button as one of the controls in it's
ItemTemplate. The Button has a CommandName="delete" attribute, but when I click it the DeleteCommand event doesn't even get fired. I have checked everything I could think of, but everything looks correct to me. Here is the relevant code from the *.aspx file and the *.aspx.vb files (if I missed something that is relevant, let me know): ASPX File: <asp:datalist id="datImages" runat="server" EnableViewState="False" CellPadding="0" CellSpacing="5" RepeatColumns="3" RepeatDirection="Horizontal" DataKeyField="contentid"> <ItemStyle HorizontalAlign="Center" VerticalAlign="Bottom"></ItemStyle> <ItemTemplate> <uc1:captionimage id="CapImg" runat="server" EnableViewState="False" photo='<%# DataBinder.Eval(Container,"DataItem.content","newsinfo/{0}").Trim() %>' caption='<%# DataBinder.Eval(Container, "DataItem.textcaption").Trim() %>'></uc1:captionimage><BR><BR> <asp:Button id="btnDeleteImg" runat="server" CausesValidation="False" Font-Bold="True" EnableViewState="False" Text="Delete" CommandName="delete"></asp:Button> </ItemTemplate> </asp:datalist> ASPX.VB File: Private Sub datImages_DeleteCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles datImages.DeleteCommand Dim cmdDelete As New OleDbCommand("DELETE FROM newsinfo WHERE contentid=" & CInt(datLinksFiles.DataKeys(e.Item.ItemIndex)), New OleDbConnection(Global.connectionstring)) cmdDelete.Connection.Open() cmdDelete.ExecuteNonQuery() cmdDelete.Connection.Close() If System.IO.File.Exists(Server.MapPath("newsinfo/" & CStr(CType(e.Item.DataItem, DataRowView).Row("content")))) Then System.IO.File.Delete(Server.MapPath("newsinfo/" & CStr(CType(e.Item.DataItem, DataRowView).Row("content")))) Me.RefreshResults() End Sub Does anybody have any idea what could be causing the datImages.DeleteCommand event not to be raised? Thank you. -- Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/ |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

