Search code examples
asp.netvb.nethyperlinkrepeatervisible

How to make Hyperlink.Visible=False if Hyperlink.Text = 0


I am trying to hide Hyperlink visibility in Repeater if there isn't any Text value in Hyperlink. Something like this:

Protected Sub rptReferenca_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles rptReferenca.ItemDataBound
    Dim lnkThumb As HyperLink = CType(rptReferenca.FindControl("lnkThumb"), HyperLink)
    If lnkThumb.Text = 0 Then
        lnkThumb.Visible = False
    End If
End Sub

But of course it doesn't work. Any help is appreciated.


Solution

  • You're almost there:

    Dim lnkThumb As HyperLink = CType(e.Item.FindControl("lnkThumb"), HyperLink)
    If lnkThumb.Text.Length = 0 Then
        lnkThumb.Visible = False
    End If
    

    Need to extract the control from the RepeaterItemEventArgs and check the Length of the text.