IF statement

S

simon

I have dataRepeater.
If the column "exists" from the database is True then I would like to show
the link button, if the value is False I would like to show only the name in
label.
Something like this:

<ItemTemplate>
<%# IF Container.DataItem( "exists" ) =true then '%>
<asp:LinkButton CausesValidation=False CommandArgument='<%#
DataBinder.Eval(Container.DataItem,"tAdv_ID")%>
CommandName="AdvType" Runat="server" ID="lnkAdvType">
<%# DataBinder.Eval(Container.DataItem,"tadv_name") %>
</asp:LinkButton>
<%# else %>
<asp:label runat=server id=lblName Text='<%#
DataBinder.Eval(Container.DataItem, "tadv_name") %>'></asp:label>
<%# end if%>
</ItemTemplate>

What is the proper way to do that?

Thank you,
Simon
 
S

simon

thank you. I know for this option.
But what if the example is more complicated and I need to use if statement.

Or with other words, how you can use IF statements here in asp.net or that
is not practice here and there is some workaround?

Thank you,
Simon
 
E

Eliyahu Goldin

Simon,

No if statement.

Have in your itemtempate both the link button and the label one next to
another. Databind Visible property of both of them to the value of the
column "exists". For the label negate the value.

Eliyahu
 
E

Eliyahu Goldin

Simon,

If you need more complex processing, you should do it in code-behind in
ItemDataBound event.

Eliyahu
 
K

Kevin Spencer

You don't need an if statement. If you want some complex logic, encapsulate
it in a property (get method), and use that.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top