I am creating a GridView dynamically, where the BoundFields is created like below:
<code>
Dim nameColumn As New BoundField()
nameColumn.DataField = "myDblNumber"
nameColumn.HeaderText = "The number"
GridView1.Columns.Add(nameColumn)
</code>
How can I make the value in the gridview (in this case a number with decimals) red if the value is negative (less than zero)? I've tried the following, which gave an error (Conversion from string "myDblNumber" to type 'Double' is not valid):
<code>
Dim nameColumn As New BoundField()
nameColumn.DataField = "myDblNumber"
nameColumn.HeaderText = "The number"
GridView1.Columns.Add(nameColumn)
If nameColumn.DataField < 0 Then
nameColumn.ItemStyle.CssClass = "errLabel"
End If
</code>
Regards,
Roy M. Halvorsen