我需要遍历gridview中的特定列。例如,我需要循环每个“%”列,然后根据它们的值分配颜色,有没有简单的方法来实现呢?谢谢。
网格视图表
行数据绑定事件
Protected Sub gv_ssi_rzli_data_1_RowDataBound(sender As Object, e As EventArgs) Handles gv_ssi_rzli_data_1.RowDataBound
Dim gv As GridView = gv_ssi_rzli_data_1
For i As Integer = 0 To gv.Rows.Count - 1
If gv.Rows(i).Cells(0).Text = "Oct" Or
gv.Rows(i).Cells(0).Text = "Nov" Or
gv.Rows(i).Cells(0).Text = "Dec" Then
If gv.Rows(i).Cells(2).Text >= Session("rzli_avg_blue_1") Then
gv.Rows(i).Cells(2).BackColor = System.Drawing.Color.LightBlue
ElseIf gv.Rows(i).Cells(2).Text >= Session("rzli_avg_green_1") And gv.Rows(i).Cells(2).Text < Session("rzli_avg_blue_1") Then
gv.Rows(i).Cells(2).BackColor = System.Drawing.Color.LightGreen
ElseIf gv.Rows(i).Cells(2).Text >= Session("rzli_avg_yellow_1") And gv.Rows(i).Cells(2).Text < Session("rzli_avg_green_1") Then
gv.Rows(i).Cells(2).BackColor = System.Drawing.Color.LightYellow
ElseIf gv.Rows(i).Cells(2).Text <= Session("rzli_avg_red_1") Then
gv.Rows(i).Cells(2).BackColor = System.Drawing.Color.LightPink
End If
End If
Next
End Sub