Doing this in VB.NET
I have a gridview RowDataBound. I want to do a test on each row column
(12). Some of the rows have NULL value.
This is the error message I'm getting.
Object cannot be cast from DBNull to other types.
This is my code I'm using.
-------------------------------
If e.Row.Cells(12) Is System.DBNull.V alue = False Then
PriceChange += Convert.ToDecim al(DataBinder.E val(e.Row.DataI tem,
"PriceChang e"))
If PriceChange < 0 Then
e.Row.Cells(12) .ForeColor = Drawing.Color.R ed
Else
If PriceChange 0 Then
e.Row.Cells(12) .ForeColor = Drawing.Color.G reen
End If
End If
End If
Can someone tell me what I'm doing wrong?
Thanks!
I have a gridview RowDataBound. I want to do a test on each row column
(12). Some of the rows have NULL value.
This is the error message I'm getting.
Object cannot be cast from DBNull to other types.
This is my code I'm using.
-------------------------------
If e.Row.Cells(12) Is System.DBNull.V alue = False Then
PriceChange += Convert.ToDecim al(DataBinder.E val(e.Row.DataI tem,
"PriceChang e"))
If PriceChange < 0 Then
e.Row.Cells(12) .ForeColor = Drawing.Color.R ed
Else
If PriceChange 0 Then
e.Row.Cells(12) .ForeColor = Drawing.Color.G reen
End If
End If
End If
Can someone tell me what I'm doing wrong?
Thanks!
Comment