其实repeater的ItemCreated和ItemCommand事件也蛮好用的。

本文介绍了ASP.NET中Repeater控件的ItemCreated和ItemCommand事件的实用案例,通过示例代码展示了如何利用这两个事件为每个项添加自定义属性及处理删除操作。

其实repeater的ItemCreated和ItemCommand事件也蛮好用的。

None.gif < asp:repeater  id ="rptsortimgUp"  runat ="server"  OnItemCommand ="rptsortimgUp_ItemCommand"  OnItemCreated ="rptsortimgUp_ItemCreated" >
None.gif                                        
< itemtemplate >
None.gif                                            
< href ='<%#  DataBinder.Eval(Container, "DataItem.f_url") % > ' target="_blank"> < img  width ="16"  height ="16"  hspace ="3"
ExpandedBlockStart.gifContractedBlock.gif                                align
="absmiddle"  src ='/Images/FileIcons/icon_<%#  DataBinder.Eval(Container, "DataItem.f_type") % > .gif' border="0"> <% dot.gif # DataBinder.Eval(Container, "DataItem.f_name" %> </ a >< span  style ="font-size:11px" >
ExpandedBlockStart.gifContractedBlock.gif                                                [
<% dot.gif # DataBinder.Eval(Container,    "DataItem.f_size""{0:N0} Bytes" %> ] </ span >
None.gif                                            
< 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">
None.gif                                            
</ asp:ImageButton >
None.gif                                        
</ itemtemplate >
None.gif                                        
< separatortemplate >
None.gif                                            |
None.gif                                        
</ separatortemplate >
None.gif                                    
</ asp:repeater >

None.gif '  添加附件删除确认
ExpandedBlockStart.gifContractedBlock.gif
     Protected   Sub rptsortimgUp_ItemCreated() Sub rptsortimgUp_ItemCreated(ByVal sender As ObjectByVal e As RepeaterItemEventArgs)
InBlock.gif        
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
InBlock.gif            
Dim myDeleteButton As ImageButton = CType(e.Item.FindControl("ibnsortimgUpDelete"), ImageButton)
InBlock.gif            myDeleteButton.Attributes.Add(
"style""cursor:hand")
InBlock.gif            myDeleteButton.Attributes.Add(
"onclick""return confirm('您确定要删除这个附件吗?')")
InBlock.gif        
End If
ExpandedBlockEnd.gif    
End Sub
  ' rptsortimgUp_ItemCreated

None.gif '  删除附件
ExpandedBlockStart.gifContractedBlock.gif
     Protected   Sub rptsortimgUp_ItemCommand() Sub rptsortimgUp_ItemCommand(ByVal sender As ObjectByVal e As RepeaterCommandEventArgs)
InBlock.gif        
If e.CommandName = "Delete" Then
InBlock.gif            Connect()
InBlock.gif            
Dim strID As String = e.CommandArgument.ToString()
InBlock.gif            FileUP.sortimgUp.Delete(conn, strID)
InBlock.gif            GetsortimgUp()
InBlock.gif            Disconnect()
InBlock.gif        
End If
ExpandedBlockEnd.gif    
End Sub
  ' rptsortimgUp_ItemCommand
posted on 2007-08-05 09:36 江宇旋 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/jiangyuxuan/archive/2007/08/05/843455.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值