2014年3月30日 星期日
GridView72絕技-文字變顏色
前台展示結果:
後台程式碼:
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
Dim oRow As Data.DataRowView
Dim oFontColor As System.Drawing.Color = Drawing.Color.Empty
If e.Row.RowType = DataControlRowType.DataRow Then
oRow = CType(e.Row.DataItem, Data.DataRowView)
'文字變顏色條件
If oRow("欄位名稱") < 1 Then
oFontColor = Drawing.Color.Black
Else
oFontColor = Drawing.Color.Red
End If
e.Row.ForeColor = oFontColor
End If
End Sub
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言