I add an image to my hyperlink column from the code behind. Unfortunately it adds the image even if no value for the field is in the database. I would like to hide the image if the value is NULL or empty.
Here is my ASPX column code:
I have tried:
Any help appreciated.
Here is my ASPX column code:
<
telerik:GridHyperLinkColumn
DataNavigateUrlFields
=
"Email"
HeaderText
=
" "
DataNavigateUrlFormatString
=
"mailto:{0}"
UniqueName
=
"Email"
AllowFiltering
=
"False"
ItemStyle-HorizontalAlign
=
"Center"
>
<
ItemStyle
Width
=
"50px"
/>
</
telerik:GridHyperLinkColumn
>
I have tried:
Private
Sub
RadGrid_ItemDataBound(
ByVal
sender
As
Object
,
ByVal
e
As
Telerik.Web.UI.GridItemEventArgs)
Handles
RadGrid2.ItemDataBound
If
(
TypeOf
e.Item
Is
GridDataItem)
Then
Dim
dataItem
As
GridDataItem =
CType
(e.Item, GridDataItem)
Dim
hyperlink
As
HyperLink =
CType
(dataItem(
"Email"
).Controls(0), HyperLink)
hyperlink.ImageUrl =
"../../../images/iconoutlook.gif"
If
(dataItem.OwnerTableView.DataKeyValues(dataItem.ItemIndex)(
"Email"
)
Is
System.DBNull.Value)
Then
Dim
ltrl
As
LiteralControl =
New
LiteralControl(hyperlink.Text)
dataItem(
"Email"
).Controls.Clear()
dataItem(
"Email"
).Controls.Add(ltrl)
End
If
End
If
End
Sub
Any help appreciated.