我想基于它在db上的值来突出显示gridview行。有一个列名checkout。如果列为NULL,则行的背景颜色为红色。如果它有值,则背景颜色为蓝色。到目前为止,这是我尝试过的。谢谢你提前
Sub barapp_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
If e.Row.DataItem("CheckOut") Is Nothing Then
e.Row.BackColor = Drawing.Color.Red
End If
End If
答案 0 :(得分:0)
试试这个。我不知道VB的确切语法,但我希望这能指导你。
Sub barapp_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
Dim rowView = (DataRowView)e.Row.DataItem;
Dim CheckOut = rowView["CheckOut"].ToString();
If CheckOut Is Nothing Then
e.Row.BackColor = Drawing.Color.Red
End If
End If