473,396 Members | 1,864 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,396 software developers and data experts.

Condition on Container.DataItem 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(DataBinder.Eval(Container.DataItem,"ImageFil ename"!="")){%>
<a href="#"><img src=<%#DataBinder.Eval(Container.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 19746

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.google.c om...
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,"ImageFil ename"!="")){%>
<a href="#"><img src=<%#DataBinder.Eval(Container.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.Eval(Container.DataItem,
"ImageFilename").ToString()=="") ? "" :"<a
href="+DataBinder.Eval(Container.DataItem, "link")+"><img
src='/Images/Products/"+DataBinder.Eval(Container.DataItem,
"ImageFilename")+"' border='0' /></a>")%>
"Neil Woodvine" <nR****************@btEinternMet.cEom> wrote in message news:<ce**********@sparta.btinternet.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.google.c om...
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,"ImageFil ename"!="")){%>
<a href="#"><img src=<%#DataBinder.Eval(Container.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
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>...
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...
1
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...
5
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...
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...
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...
3
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...
3
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"...
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>
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
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
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...

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.