P
pvong
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.Value = False Then
PriceChange += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem,
"PriceChange"))
If PriceChange < 0 Then
e.Row.Cells(12).ForeColor = Drawing.Color.Red
Else
If PriceChange > 0 Then
e.Row.Cells(12).ForeColor = Drawing.Color.Green
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.Value = False Then
PriceChange += Convert.ToDecimal(DataBinder.Eval(e.Row.DataItem,
"PriceChange"))
If PriceChange < 0 Then
e.Row.Cells(12).ForeColor = Drawing.Color.Red
Else
If PriceChange > 0 Then
e.Row.Cells(12).ForeColor = Drawing.Color.Green
End If
End If
End If
Can someone tell me what I'm doing wrong?
Thanks!