I have a radgird that will be displaying support tickets. Within the grid I am using the telerik:GridImageColumn to display either a green, yellow or red image.
I am current trying to achieve this with itemdatabound, using findcontrol. I keep getting an error “Object reference not set to an instance of an object.”. Can some let me know what I am doing wrong?
Thanks
(
If
TypeOf e.Item Is GridDataItem Then
Dim dataItem As GridDataItem = DirectCast(e.Item, GridDataItem)
Dim dataBoundItem As GridDataItem = e.Item
Dim calcdate As Date
Dim tsTimeSpan As TimeSpan
Dim iNumberOfDays As Integer
calcdate = dataItem.DataItem(
"SubmitDate")
tsTimeSpan = Now.Subtract(calcdate)
iNumberOfDays = tsTimeSpan.Days
If iNumberOfDays < 2 Then
dataBoundItem.FindControl(
"imggreen").Visible = True
ElseIf iNumberOfDays = 2 Then
dataBoundItem.FindControl(
"imgyellow").Visible = True
dataItem(
"SubmitDate").BackColor = Color.Yellow
ElseIf iNumberOfDays >= 3 Then
dataBoundItem.FindControl(
"imgred").Visible = True
dataItem("SubmitDate").BackColor = Color.Red
End If
End If
)