html5中文学习网

您的位置: 首页 > 网络编程 > ASP.NET » 正文

鼠标移动,改变datagrid颜色_.NET教程_编程技术

[ ] 已经帮助:人解决问题
datagrid
Sub DataGrid1_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)

If e.Item.ItemType = ListItemType.Item Or _
e.Item.ItemType = ListItemType.AlternatingItem Then

'---------------------------------------------------
' Add the OnMouseOver and OnMouseOut method to the Row of DataGrid
'---------------------------------------------------
e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='Silver'")
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='white'")

End If

End Sub

Sub DataGrid2_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs)

If e.Item.ItemType = ListItemType.Item Or _
e.Item.ItemType = ListItemType.AlternatingItem Then

'---------------------------------------------------
' Add the OnMouseOver and OnMouseOut method a Cell (Column) of DataGrid
'---------------------------------------------------
e.Item.Cells(1).Attributes.Add("onmouseover", "this.style.backgroundColor='#DDEEFF'")
e.Item.Cells(1).Attributes.Add("onmouseout", "this.style.backgroundColor='white'")

'---------------------------------------------------
' Change the Mouse Cursor of a particular Cell (Column) of DataGrid
' (Or you may do it for a whole Row of DataGrid :)
'---------------------------------------------------
e.Item.Cells(3).Style("cursor") = "hand"

'---------------------------------------------------
' Add the OnClick Alert MessageBox to a particular Cell (Column) of DataGrid
'---------------------------------------------------
e.Item.Cells(3).Attributes.Add("onclick", "alert('You click at ID: " & e.Item.Cells(0).Text & "!');")

End If
End Sub

RbEHTML5中文学习网 - HTML5先行者学习网
RbEHTML5中文学习网 - HTML5先行者学习网
(责任编辑:)
推荐书籍
推荐资讯
关于HTML5先行者 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 人才招聘 - 帮助