Condition in repeater...

  • Thread starter Thread starter =?iso-8859-1?Q?C=E9dric?=
  • Start date 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
 
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")) %>
 
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")) %>
 
Back
Top