473,421 Members | 1,500 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,421 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 19749

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
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
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
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...
1
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
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.