2012-04-02
作用:當滑鼠滑到資料列時,能將該列資料利用顏色特別顯示出來,滑開時又恢復了原來的底色.
在GridView的RowDataBound加入每列的屬性值
If e.Row.RowType = DataControlRowType.DataRow Then
'設定狀態
Dim lblStatus As Label = e.Row.FindControl("lblStatus")
Dim lblStatusName As Label = e.Row.FindControl("lblStatusName")
Select Case lblStatus.Text
Case "P"
lblStatusName.Text = "準備"
e.Row.BackColor = Drawing.Color.LavenderBlush
Case "Y"
lblStatusName.Text = "上架"
e.Row.BackColor = Drawing.Color.White
Case "N"
lblStatusName.Text = "下架"
e.Row.BackColor = Drawing.Color.LightGray
End Select
'==設定滑鼠經過時變色
e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='Gold';")
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c")
'本語法可在離開時,讓列回覆原來設定的顏色
End If
5
章老師的電腦小講堂: ASP.NET GRIDVIEW的背光設定
作用:當滑鼠滑到資料列時,能將該列資料利用顏色特別顯示出來,滑開時又恢復了原來的底色. 在GridView的RowDataBound加入每列的屬性值 If e.Row.RowType = DataControlRowType.DataRow Then ...