停留的风 阅读(554) 评论(0) 编辑 收藏 所属分类: .NET技巧特辑
如何在DataGrid中点击删除时弹出确认,按"确定"时实施删除?
在datagrid的ItemDataBound事件加入以下这句:
e.Item.Cells(1).Attributes.Add("onClick", "return confirm('你确定要删除这一项吗?');")
顺便附送:一句很有用的代码:(用于在鼠标划过时,高亮显示划过项)
If e.Item.ItemIndex > -1 Then
e.Item.Attributes.Add("onmouseover", "currentcolor=this.style.backgroundColor;this.style.backgroundColor='#F0F5FF';this.style.color='Red'")
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor=currentcolor;this.style.color='black'")
End If
e.item.itemIndex=-1为列表头.
以上代码都是用在itemDataBound事件中<