[ASP.NET]讓DataGrid有那種選到該列就變顏色的效果
如何讓DataGrid有那種選到該列就變顏色的效果呢?
Step 1.
實作ItemCreated事件
Private Sub dgdBlockCourse_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgdBlockCourse.ItemCreated
e.Item.Attributes.Add("onmouseover", "javascript:this.className='blueon'")
e.Item.Attributes.Add("onmouseout", "javascript:this.className='blueoff'")
e.Item.Attributes.Add("class", "White")
End Sub
記得在網頁中引用或加入Css的屬性
{
BACKGROUND-COLOR: #ccccff
}
.blueoff
{
BACKGROUND-COLOR: white
}
如此一來就會有變色的效果了…
Step 1.
實作ItemCreated事件
Private Sub dgdBlockCourse_ItemCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles dgdBlockCourse.ItemCreated
e.Item.Attributes.Add("onmouseover", "javascript:this.className='blueon'")
e.Item.Attributes.Add("onmouseout", "javascript:this.className='blueoff'")
e.Item.Attributes.Add("class", "White")
End Sub
記得在網頁中引用或加入Css的屬性
{
BACKGROUND-COLOR: #ccccff
}
.blueoff
{
BACKGROUND-COLOR: white
}
如此一來就會有變色的效果了…
留言