我的gridview列中有一个值,它将确定整行的值是否应为红色。我做了以下但不知何故,每一行都是红色的。请善意的建议。感谢。
Protected Sub uigvList_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles uigvList.RowCreated
If e.Row.RowType = DataControlRowType.DataRow Then
If Not (DataBinder.Eval(e.Row.DataItem, "VoidOn")) Is Nothing Then ' This is the condition, if this field is not blank then I want to the entire row to have red colored values.
e.Row.BackColor = Drawing.Color.Firebrick
End If
End If
End Sub
答案 0 :(得分:1)
也许 DBNull.Value ?
If (DataBinder.Eval(e.Row.DataItem, "VoidOn")) IsNot DBNull.Value Then ...
If e.Row.DataItem("VoidOn") IsNot DBNull.Value Then ...
PS:您可以在调试模式下检查 VoidOn 值,只需将断点设置为代码行。