Dim L As Label
Dim i As Integer
For i = 0 To DataGrid1.Items.Count
L = DataGrid1.Items(i).FindControl("label")
If Not L Is Nothing Then
L.ForeColor = IIf(DataGrid1.Items(i).Cells(0).Text = "类别", Color.Red, Color.Black)
End If
Next
用模板列
Dim L As Label
Dim i As Integer
For i = 0 To DataGrid1.Items.Count
L = DataGrid1.Items(i).FindControl("label")
If Not L Is Nothing Then
L.ForeColor = IIf(DataGrid1.Items(i).Cells(0).Text = "类别", Color.Red, Color.Black)
End If
Next