日期:2014-05-18  浏览次数:20411 次

Vb.NET 做的web程序中, 怎么样可以根据某一个字段内容不同(比如:字段=1或0)而让datagridview中的行的记录变颜色呢?
Vb.NET 做的web程序中, 怎么样可以根据某一个字段内容不同(比如:字段=1或0)而让datagridview中的行的记录变颜色呢?
请指教,谢谢!

------解决方案--------------------
If e.Row.RowIndex >= 0 Then
For i = 0 To GridView1.Rows.Count 
If GridView1.Rows(i).Cells("status").Text.ToString = "未开始" Then 
GridView1.Rows(i).BackColor = Color.DarkGreen 
End If 
Next 
 End If

------解决方案--------------------
应该不用for循环的,用参数e就可以,代码是我根据C#改的,仅供参考。
Protected Sub GridView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.DataBound

If e.Row.Cells("status").Text.ToString = "未开始" Then
e.Row.BackColor = Color.DarkGreen
End If


End Sub