473,399 Members | 3,603 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Condition in repeater...

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

Nov 17 '05 #1
2 5167
Jos
Cédric wrote:
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,"My Field")) %>

--

Jos
Nov 17 '05 #2
Thx Jos!!

\Cédric
-----Original Message-----
Cédric wrote:
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")) %>
--

Jos
.

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: az bij | last post by:
Hi, I have a dataset bound to a repeater and want to place some logic in my ascx file. I want to display an image link if and only if an image is available. I have tried without success...
1
by: Troy Stanley - CyberWarehouse.com | last post by:
How does one evaluate if a field is null to display it in the datalist or repeater? I have tried a number of different things... Would anyone know how to do this? <asp:Repeater id="customers"...
4
by: Bernie V | last post by:
Hi group, Is it possible to use a condition in a repeater control ? I 'd like to use a condition to create this <a href='<%#DataBinder.Eval(Container.DataItem,"nieuwsid")%>.aspx'> part of the...
0
by: Zenobia | last post by:
This code, for a page control, is supposed to print a gif (for each new year, followed by the text of each year). It doesn't do that. It is just a simplified version of another control used for...
1
by: Shari | last post by:
I am trying to use a repeater control in an ASP.NET application (codebehind is C#), to display a bunch of error messages after a validation has occurred. In the codebehind, I have access to the...
1
by: Theodor Ramisch | last post by:
Hi there, i got a Repeater control which repeats through some rows and should display a WebControl depending on a value of the row: It should be something like that: <asp:Repeater...
4
by: kelvinweb | last post by:
Hi All, My Source Code is the following <ItemTemplate> <tr> <td width="100" align="right"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">&nbsp;</font></td> <%IF...
2
by: HockeyFan | last post by:
I have the following inside a repeater: <ItemTemplate> <b><%#Container.DataItem("TitleText")%></b><br /> <%#Container.DataItem("ParagraphText")%> <br /><br /> </ItemTemplate>
4
by: Michael | last post by:
I have a repeater web control. Currently I want to change some row's color based on defined condition. Is there any code sample demonstrating how to accomplish it? Thanks.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.