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.

4

3 回答 3

1

Try changing this:

If lnkThumb.Text = 0 Then

...to this:

If lnkThumb.Text.Length = 0 Then
于 2011-01-20T13:41:47.963 回答
0

Not sure how VB handles this but you are checking a string against an int.

Maybe

If lnkThumb.Text = "0" Then
    lnkThumb.Visible = False
End If
于 2011-01-20T13:40:51.210 回答
0

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.

于 2011-01-20T13:42:03.520 回答