Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Using conditional logic in VB to have LinkButton be visible (or not visible)

Posted on 2008-06-10
2
Medium Priority
?
223 Views
Last Modified: 2013-11-07
I have a DataList that contains several Labels and a LinkButton in both the Item & Alternating Item Templates.  One of the labels, Label7, displays a numeric value.
My problem is this:  I only want LinkButton1 to be visible if the value of Label7 > 0
How do I do this with VB.NET?
Thanks in advance for any advice.
0
Comment
Question by:DanGettel
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 22

Accepted Solution

by:
prairiedog earned 2000 total points
ID: 21751474
DataList can fire an event called ItemDataBound, you can use it to accomplish your mission.

Private Sub DataListl_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles DataListl.ItemDataBound
        If (e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem) Then
 
            Dim lbl As Label = CType(e.Item.FindControl("Label7"), Label)
            Dim lnkbtn As LinkButton = CType(e.Item.FindControl("myLinkButton"), LinkButton)
            If (lnkbtn IsNot Nothing) AndAlso (lbl IsNot Nothing) Then
                If (Int32.Parse(lbl.Text) > 7) Then
                   lnkbtn.Visible = True
                Else
                   lnkbtn.Visible = False
                End If
            End If
        End If
    End Sub

Open in new window

0
 
LVL 22

Assisted Solution

by:prairiedog
prairiedog earned 2000 total points
ID: 21751496
Sorry, this line: Int32.Parse(lbl.Text) > 7
should be Int32.Parse(lbl.Text) >  0
0

Featured Post

Not sure which OpenStack Certification to get?

So you’ve realized you might want to get certified in OpenStack, but you’re not sure what the benefits might be or even which one you should take. You know there are several certification courses you can choose from, but how do you know which one is right for you?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question