其实repeater的ItemCreated和ItemCommand事件也蛮好用的。
<asp:repeater id="rptsortimgUp" runat="server" OnItemCommand="rptsortimgUp_ItemCommand" OnItemCreated="rptsortimgUp_ItemCreated">
<itemtemplate>
<a href='<%# DataBinder.Eval(Container, "DataItem.f_url") %>' target="_blank"><img width="16" height="16" hspace="3"
align="absmiddle" src='/Images/FileIcons/icon_<%# DataBinder.Eval(Container, "DataItem.f_type") %>.gif' border="0"><%# DataBinder.Eval(Container, "DataItem.f_name") %></a><span style="font-size:11px">
[<%# DataBinder.Eval(Container, "DataItem.f_size", "{0:N0} Bytes") %>]</span>
<asp:ImageButton ID="ibnsortimgUpDelete" ImageUrl="/Images/icon_delete.gif" Width="13" Height="13" ImageAlign="AbsMiddle" CommandName="Delete" CommandArgument='<%# DataBinder.Eval(Container, "DataItem.f_id") %>' causesvalidation="False" runat="server">
</asp:ImageButton>
</itemtemplate>
<separatortemplate>
|
</separatortemplate>
</asp:repeater>
<itemtemplate>
<a href='<%# DataBinder.Eval(Container, "DataItem.f_url") %>' target="_blank"><img width="16" height="16" hspace="3"
align="absmiddle" src='/Images/FileIcons/icon_<%# DataBinder.Eval(Container, "DataItem.f_type") %>.gif' border="0"><%# DataBinder.Eval(Container, "DataItem.f_name") %></a><span style="font-size:11px">
[<%# DataBinder.Eval(Container, "DataItem.f_size", "{0:N0} Bytes") %>]</span>
<asp:ImageButton ID="ibnsortimgUpDelete" ImageUrl="/Images/icon_delete.gif" Width="13" Height="13" ImageAlign="AbsMiddle" CommandName="Delete" CommandArgument='<%# DataBinder.Eval(Container, "DataItem.f_id") %>' causesvalidation="False" runat="server">
</asp:ImageButton>
</itemtemplate>
<separatortemplate>
|
</separatortemplate>
</asp:repeater>
' 添加附件删除确认
Protected Sub rptsortimgUp_ItemCreated(ByVal sender As Object, ByVal e As RepeaterItemEventArgs)
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
Dim myDeleteButton As ImageButton = CType(e.Item.FindControl("ibnsortimgUpDelete"), ImageButton)
myDeleteButton.Attributes.Add("style", "cursor:hand")
myDeleteButton.Attributes.Add("onclick", "return confirm('您确定要删除这个附件吗?')")
End If
End Sub 'rptsortimgUp_ItemCreated
Protected Sub rptsortimgUp_ItemCreated(ByVal sender As Object, ByVal e As RepeaterItemEventArgs)
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
Dim myDeleteButton As ImageButton = CType(e.Item.FindControl("ibnsortimgUpDelete"), ImageButton)
myDeleteButton.Attributes.Add("style", "cursor:hand")
myDeleteButton.Attributes.Add("onclick", "return confirm('您确定要删除这个附件吗?')")
End If
End Sub 'rptsortimgUp_ItemCreated
' 删除附件
Protected Sub rptsortimgUp_ItemCommand(ByVal sender As Object, ByVal e As RepeaterCommandEventArgs)
If e.CommandName = "Delete" Then
Connect()
Dim strID As String = e.CommandArgument.ToString()
FileUP.sortimgUp.Delete(conn, strID)
GetsortimgUp()
Disconnect()
End If
End Sub 'rptsortimgUp_ItemCommand
Protected Sub rptsortimgUp_ItemCommand(ByVal sender As Object, ByVal e As RepeaterCommandEventArgs)
If e.CommandName = "Delete" Then
Connect()
Dim strID As String = e.CommandArgument.ToString()
FileUP.sortimgUp.Delete(conn, strID)
GetsortimgUp()
Disconnect()
End If
End Sub 'rptsortimgUp_ItemCommand
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步