473,722 Members | 2,338 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Condition on Container.DataI tem in inline code

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 variations of:

<%#if(DataBinde r.Eval(Containe r.DataItem,"Ima geFilename"!="" )){%>
<a href="#"><img src=<%#DataBind er.Eval(Contain er.DataItem,
"ImageFilename" )%>/></a>
<%}%>
The above gives: Compiler Error Message: CS1513: } expected

Replacing the last <%}%> with <%#}%> gives: CS1525: Invalid expression
term 'if'
And if I remove the # from the first directive: CS0246: The type or
namespace name 'Container' could not be found

It's driving me mad. Can anyone help please?

Thanks,
Andy
Jul 21 '05 #1
2 19780

Have not used the Repeater before, but for DataBinding statement in DataGrid
and DataList you need to use the IIF statement for conditional processing.

e.g.
iif(DataBinder. Eval(Container. DataItem, "ImageFilename" ) = "", "", "<a href
..... etc")

Also, note position of first closing parenthesis. You need to resolve the
DataBinder.Eval statement before testing it against the empty string.

Cheers,
Neil
"az bij" <az***@hotmail. com> wrote in message
news:5f******** *************** ***@posting.goo gle.com...
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 variations of:

<%#if(DataBinde r.Eval(Containe r.DataItem,"Ima geFilename"!="" )){%>
<a href="#"><img src=<%#DataBind er.Eval(Contain er.DataItem,
"ImageFilename" )%>/></a>
<%}%>
The above gives: Compiler Error Message: CS1513: } expected

Replacing the last <%}%> with <%#}%> gives: CS1525: Invalid expression
term 'if'
And if I remove the # from the first directive: CS0246: The type or
namespace name 'Container' could not be found

It's driving me mad. Can anyone help please?

Thanks,
Andy

Jul 21 '05 #2
Thanks a lot Neil.

got there in the end..

<%# ((DataBinder.Ev al(Container.Da taItem,
"ImageFilename" ).ToString()==" ") ? "" :"<a
href="+DataBind er.Eval(Contain er.DataItem, "link")+">< img
src='/Images/Products/"+DataBinder.Ev al(Container.Da taItem,
"ImageFilename" )+"' border='0' /></a>")%>
"Neil Woodvine" <nR************ ****@btEinternM et.cEom> wrote in message news:<ce******* ***@sparta.btin ternet.com>...
Have not used the Repeater before, but for DataBinding statement in DataGrid
and DataList you need to use the IIF statement for conditional processing.

e.g.
iif(DataBinder. Eval(Container. DataItem, "ImageFilename" ) = "", "", "<a href
.... etc")

Also, note position of first closing parenthesis. You need to resolve the
DataBinder.Eval statement before testing it against the empty string.

Cheers,
Neil
"az bij" <az***@hotmail. com> wrote in message
news:5f******** *************** ***@posting.goo gle.com...
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 variations of:

<%#if(DataBinde r.Eval(Containe r.DataItem,"Ima geFilename"!="" )){%>
<a href="#"><img src=<%#DataBind er.Eval(Contain er.DataItem,
"ImageFilename" )%>/></a>
<%}%>
The above gives: Compiler Error Message: CS1513: } expected

Replacing the last <%}%> with <%#}%> gives: CS1525: Invalid expression
term 'if'
And if I remove the # from the first directive: CS0246: The type or
namespace name 'Container' could not be found

It's driving me mad. Can anyone help please?

Thanks,
Andy

Jul 21 '05 #3

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

Similar topics

2
5180
by: Cédric | last post by:
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" {
4
7812
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 repeater At the moment I use "nieuwsid" to make the url but in some cases it has to be <a href='wcharts.aspx'> Is that possible ?
1
2870
by: anony | last post by:
Hi, I would like to find out if it's possible to check the value of a Container.DataItem inside the Datagrid's <ItemTemplate> tag .... based on it's value, I would to either output it or output another DataItem from the current resultset. Something like this: <ItemTemplate> If container.dataitem( "column" ) <> "none" Then
5
724
by: bg | last post by:
Hi! How do I check if "date" exists before using that code? I've built a RSSreader and sometimes there's a date in it and sometimes not. How can I check if it exists to avoid crash (DataBinder.Eval: 'System.Data.DataRowView' does not contain a property with the name date) <asp:DataGrid id="RssNewsGrid"
0
1108
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 demonstration that has the same bug. 1) The <HeaderTemplate> displays the 2004 gif and sets the value of sPubYY = 2004. 2) When the <ItemTemplate> code executes sPubYY has been set =
2
3217
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 variations of: <%#if(DataBinder.Eval(Container.DataItem,"ImageFilename"!="")){%> <a href="#"><img src=<%#DataBinder.Eval(Container.DataItem,
3
3427
by: Agnes | last post by:
I use repater to show the data(invoice), the last column (download button) for the user to download the invoice copy However, if the invoice had been settled, the download must bet disable or visible to false. I try to use if ... then statment to do , but it seesm fail. Please help <%# If Container.DataItem("paid") = "Y" Then%> <td><form action="download.aspx" > <input type="button" value="Download"............."> </FORM></td>
3
2860
by: vishnu | last post by:
Hi, I have a link that is coming from the database.Now if the link is empty i dont want to display in datalist .How can i do that? <td><asp:DataList id="DataList1" Runat="server" RepeatDirection="Horizontal" RepeatColumns="3" CellPadding="5" CellSpacing="2" Width="100%" EnableViewState="False"> <itemtemplate> <b>
2
1540
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>
0
8863
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8739
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9384
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9238
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6681
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4502
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4762
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2147
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.