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

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top