This is a migrated thread and some comments may be shown as answers.

GridColumn make visible = true

1 Answer 67 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dwayne Starkey
Top achievements
Rank 1
Dwayne Starkey asked on 26 Apr 2010, 07:01 PM

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

 

)

1 Answer, 1 is accepted

Sort by
0
Dwayne Starkey
Top achievements
Rank 1
answered on 26 Apr 2010, 08:10 PM
I got it....at least a work around

instead of using a radimagecolumn I used a radbutton column using the button type image. I then pass the image url in the itemdatabound depending on the days. Sample of what worked below.

      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  
 
            Dim imgCol As GridImageColumn = DirectCast(RadGridGetTickets.MasterTableView.GetColumn("imgTT"), GridImageColumn)  
 
 
            If iNumberOfDays < 2 Then  
 
                CType(dataItem("BtnTTImg").Controls(0), ImageButton).ImageUrl = "~/CMSC-Images/Icons/helpdesk/green_alert.gif" 
 
 
            ElseIf iNumberOfDays = 2 Then  
 
                CType(dataItem("BtnTTImg").Controls(0), ImageButton).ImageUrl = "~/CMSC-Images/Icons/helpdesk/yellow_alert.png" 
 
            ElseIf iNumberOfDays >= 3 Then  
 
                CType(dataItem("BtnTTImg").Controls(0), ImageButton).ImageUrl = "~/CMSC-Images/Icons/helpdesk/red_alert.gif" 
 
            Else  
 
            End If  
 
        End If  
 
Tags
Grid
Asked by
Dwayne Starkey
Top achievements
Rank 1
Answers by
Dwayne Starkey
Top achievements
Rank 1
Share this question
or