Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > IF statement

Reply
Thread Tools

IF statement

 
 
simon
Guest
Posts: n/a
 
      09-22-2004
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


 
Reply With Quote
 
 
 
 
simon
Guest
Posts: n/a
 
      09-22-2004
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

"Eliyahu Goldin" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
> "simon" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > 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
> >
> >

>
>



 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      09-22-2004
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

"simon" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
Eliyahu Goldin
Guest
Posts: n/a
 
      09-22-2004
Simon,

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

Eliyahu

"simon" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
> "Eliyahu Goldin" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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
> >
> > "simon" <(E-Mail Removed)> wrote in message
> > news:%(E-Mail Removed)...
> > > 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
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Kevin Spencer
Guest
Posts: n/a
 
      09-22-2004
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

"simon" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
> "Eliyahu Goldin" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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
> >
> > "simon" <(E-Mail Removed)> wrote in message
> > news:%(E-Mail Removed)...
> > > 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
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
if statement that, when false, skips first statement in its block, executes second? Jay McGavren Java 11 01-16-2006 05:49 PM
How do I do a conditional statement in a constant statement? tkvhdl@gmail.com VHDL 3 12-16-2005 06:13 PM
Which of switch statement and if-else statement takes less time to execute? swaroophr@gmail.com C Programming 21 08-02-2005 09:24 AM
exec "statement" VS. exec "statement in globals(), locals() Ted Python 1 07-22-2004 08:51 AM
exec "statement" VS. exec "statement" in globals(), locals() tedsuzman Python 2 07-21-2004 08:41 PM



Advertisments