I’m using Visual Studio 2007 and I’m using a grid view control to display data. One of the fields in the gridview control displays numeric data. If the numeric data is less than zero, then I want the backcolor to be red.
1. I have changed the field that displays the data to a template field.
2. I changed the name of the label in the template field from Label1 to lblAmount
In the databinding event of the grid control I placed the following code
When I run this code I get an error Object reference not set to an instance of an object.Code:Dim lblAmount As Label = Me.GridView1.FindControl("lblAmount") If lblAmount.Text < 0 Then lblAmount.BackColor = Color.Red End If
I have tried this code in the databinding and databound event of my gridview control and I get the same error. How can I accomplish what I want – making the label red?
Thanks
GEM




Reply With Quote