471,108 Members | 1,587 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,108 software developers and data experts.

DataList.DeleteCommand event is not getting fired

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","news info/{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
nj********@hotmail.com
http://www.nathansokalski.com/
May 21 '06 #1
0 782

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Barry | last post: by
2 posts views Thread by Chris Fink | last post: by
reply views Thread by Ashish Sharma | last post: by
2 posts views Thread by Jim Heavey | last post: by
5 posts views Thread by TCORDON | last post: by
4 posts views Thread by Patrick.O.Ige | last post: by
2 posts views Thread by cindy | last post: by
2 posts views Thread by haroldsphsu | last post: by
4 posts views Thread by Nathan Sokalski | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.