Solved

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

Posted on 2008-06-10
2
222 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 500 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 500 total points
ID: 21751496
Sorry, this line: Int32.Parse(lbl.Text) > 7
should be Int32.Parse(lbl.Text) >  0
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

623 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