Question: Is there a way to do a conditional statement in C# for my asp.net page? I want it to be, basically:

```
if bool is true, add <a href>

```

I've got this:

```
<asp:Label ID="BenLabel" CssClass='<%#((Entry)(Container.DataItem)).HasBenform ? "EnabledEntry" : "DisabledEntry"%>' Text="Benefits Form" runat="server" />

```

In this way it changes its CSS class based on the bool value. However, is it possible for me to add a link, too? How would I code this?

Answer: 
Add an `HyperLink` and then render it `Visible` based on this boolean condition.

```
<asp:HyperLink ID="BenLink" Visible='<%# ((Entry)(Container.DataItem)).HasBenform %>' ... runat="server" />

```
I like to handle this sort of logic in the code behind on page\_init or Page\_Load.

Something like this

```
If (NeedToShowLink)
{
    Link.Visible = true;
}
else
{
    Link.Visible = false;
}

```