I have an ASP.NET image control in a templated column within RadGrid (lastest release)
I have been able to adjust the background color of the cell as shown in the code below. However, the client prefers that I use customized icons that would vary based on several data conditions.
I am hoping there is a way that I can access the ImageUrl property of the control in this cell.
Note that this control differs from my color-coding example quoted below, but I think that whatever statement I need would fit into that overall logic.
I have been able to adjust the background color of the cell as shown in the code below. However, the client prefers that I use customized icons that would vary based on several data conditions.
I am hoping there is a way that I can access the ImageUrl property of the control in this cell.
Note that this control differs from my color-coding example quoted below, but I think that whatever statement I need would fit into that overall logic.
<
telerik:GridTemplateColumn
DataField
=
"id"
FilterControlAltText
=
"Filter column column"
HeaderText
=
"Info"
UniqueName
=
"ID_column"
SortExpression
=
"id"
>
<
ItemTemplate
>
<
asp:Image
ID
=
"targetControl"
runat
=
"server"
ImageUrl
=
"images/info16.gif"
/>
</
ItemTemplate
>
Protected Sub Event_Grid_ItemCreated(sender As Object, e As Telerik.Web.UI.GridItemEventArgs) Handles Event_Grid.ItemCreated
Dim Temp As String = Nothing
Dim Event_Date As Date = Nothing
Dim End_Date As Date = Nothing
If TypeOf (e.Item) Is GridDataItem Then
Try
Event_Date = CDate(e.Item.DataItem("event_date_sort"))
End_Date = CDate(e.Item.DataItem("end_date"))
Dim gdi As GridDataItem = CType(e.Item, GridDataItem)
If End_Date <
Today
Then
gdi.Cells(2)
.BackColor
=
System
.Drawing.Color.Silver
ElseIf (End_Date >= Today) And (Event_Date <= Today) Then
gdi.Cells(2).BackColor = System.Drawing.Color.PaleGreen
ElseIf Event_Date < DateAdd(DateInterval.Month, 1, Today) Then
gdi.Cells(2).BackColor = System.Drawing.Color.Yellow
Else
gdi.Cells(2).BackColor = System.Drawing.Color.WhiteSmoke
End If
If e.Item.DataItem("type_code") = "x" Then
gdi.Cells(2).BackColor = System.Drawing.Color.Tomato
End If
Catch ex As Exception
'leave default shading
End Try
End If
End Sub