高亮显示基于列值为null的网格视图行



我想根据它在数据库上的值突出显示网格视图行。。有一个列名签出。如果列为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

试试这个。我不知道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

最新更新