4月 02, 2012

GridView 設定文字底色


Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
        'e.Row.Cells(1).BackColor = System.Drawing.Color.LightBlue
        'GridView1.Columns(0).ItemStyle.BackColor = System.Drawing.Color.LightBlue
        'GridView1.Rows(0).Cells(0).BackColor = System.Drawing.Color.LightBlue
        For i As Integer = 0 To GridView1.Rows.Count - 1
            For j As Integer = 0 To 38
                If GridView1.Rows(i).Cells(j).Text.Length = 2 Then
                    GridView1.Rows(i).Cells(j).BackColor = System.Drawing.Color.LightBlue
                End If
            Next
        Next
End Sub

沒有留言: