Condition in repeater...

  • Thread starter =?iso-8859-1?Q?C=E9dric?=
  • Start date
?

=?iso-8859-1?Q?C=E9dric?=

Hi,

Is there any easy way to have a condition in a repeater?
I would like to do something like this (of course this
does not work):

<asp:Repeater id="rpt" runat="Server">
<ItemTemplate>
<%# if DataBinder.Eval
(Container.DataItem, "MyField").ToString() ) == "X" {
response.write "ABC";
} else {
response.write "EFG";
}
%>
</ItemTemplate>
</asp:Repeater>

Thx for your help!

\Cédric
 
J

Jos

Cédric said:
Hi,

Is there any easy way to have a condition in a repeater?
I would like to do something like this (of course this
does not work):

<asp:Repeater id="rpt" runat="Server">
<ItemTemplate>
<%# if DataBinder.Eval
(Container.DataItem, "MyField").ToString() ) == "X" {
response.write "ABC";
} else {
response.write "EFG";
}
%>
</ItemTemplate>
</asp:Repeater>

Thx for your help!

\Cédric

Just put your code in a function
string mycondition(object o) {
if o.ToString() ) == "X" {
return "ABC";
} else {
return "EFG";
}
}

Then use this databinding expression:
<%# mycondition(DataBinder.Eval(Container.DataItem,"MyField")) %>
 
G

Guest

Thx Jos!!

\Cédric


-----Original Message-----


Just put your code in a function
string mycondition(object o) {
if o.ToString() ) == "X" {
return "ABC";
} else {
return "EFG";
}
}

Then use this databinding expression:
<%# mycondition(DataBinder.Eval
(Container.DataItem,"MyField")) %>
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top