鼠标经过的行高亮显示(在datagrid中)
当页面显示一个数据繁多的表格时,为了便于用户的查看,可以将鼠标经过的行高亮显示.
1
Private Sub dgSupply_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgSupply.ItemDataBound
2
3
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
4
'添加自定义属性,当鼠标移过来时设置该行的背景色为"6699ff",并保存原背景色
5
e.Item.Attributes.Add("onmouseover", "StyleColor=this.style.backgroundColor;this.style.backgroundColor='#6699ff'")
6
'添加自定义属性,当鼠标移走时还原该行的背景色
7
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor=StyleColor")
8
End If
9
End Sub
Private Sub dgSupply_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgSupply.ItemDataBound2
3
If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then4
'添加自定义属性,当鼠标移过来时设置该行的背景色为"6699ff",并保存原背景色5
e.Item.Attributes.Add("onmouseover", "StyleColor=this.style.backgroundColor;this.style.backgroundColor='#6699ff'")6
'添加自定义属性,当鼠标移走时还原该行的背景色7
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor=StyleColor")8
End If9
End Sub

浙公网安备 33010602011771号