473,399 Members | 3,302 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.

Conditionally display image within FormView

I'm using a SqlDataSource to fetch data and display it in a FormView. One
of the elements is an image:

<asp:Image ID="ImageFile" runat="server" ImageURL='<%# Eval("ImageFile",
"~/storyimages/{0}") %>' />

However, sometimes there is no image to display, and therefore I want to set
the Image control's Visible property to false. I tried evaluating whether
the ImageFile field has a vlaue or not and using it to set the Visible
property like so:
Visible='<%# Eval("ImageFile") != DBNull.Value %>'

Nor does Visible='<%# Eval("ImageFile").ToString()!=null%>'

Can anyone point me ion the right direction?

Thanks
Dec 30 '06 #1
1 2717

"Mike" <xx*@xxx.xxxwrote in message
news:uS*************@TK2MSFTNGP06.phx.gbl...
I'm using a SqlDataSource to fetch data and display it in a FormView. One
of the elements is an image:

<asp:Image ID="ImageFile" runat="server" ImageURL='<%# Eval("ImageFile",
"~/storyimages/{0}") %>' />

However, sometimes there is no image to display, and therefore I want to
set the Image control's Visible property to false. I tried evaluating
whether the ImageFile field has a vlaue or not and using it to set the
Visible property like so:
Visible='<%# Eval("ImageFile") != DBNull.Value %>'

Nor does Visible='<%# Eval("ImageFile").ToString()!=null%>'
Ignore this. I discovered my empty database fields were not nulls. They
contained empty strings. I updated the db, and now the above works fine.

Doh.
Dec 31 '06 #2

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

Similar topics

3
by: Mark | last post by:
Hello all - I'm at wits end with trying to figure out why I'm having this problem since I followed the research, that I've dug up, to a "T". I'm trying to display a JPEG image from a path...
1
by: Paolo Pignatelli | last post by:
I have a database containing an ImageURL3 column, in which the default is ~/Images/No-Image.gif . I would like to dispaly the images from the column in a webpage,l as long as they are not the...
3
by: | last post by:
One thing I did a lot of in Classic ASP involved showing page elements conditionally based on whether a user was logged in or not. Logged in users or "superusers" would get more content and/or more...
0
by: Neil | last post by:
I'm using a formview but have come across a frustrating problem. If I have the width of the formview set to a specific size e.g. 960px I can see all the template as it would be displayed to a...
4
by: Guy | last post by:
I'm a little bit confused as what is the bes way to achieve the following: I have 2 database tables, table 1 product en table 2 image. For every product record there can be 0-1 or more image...
1
by: scartin | last post by:
I'm fairly new to working with ASP web controls, and am running into what seems to be a ridiculous problem that I'm hoping will be a breeze for an experienced ASP developer. I have a GridView...
2
by: Felix | last post by:
Hello, I use a #define like WITH_MYSTUFF to conditionally compile code within #ifdef WITH_MYSTUFF. I would now like the same define to conditionally link with a library. In the linker settings...
0
by: Chris | last post by:
I have a formview nested within a formview. It child formview will be the same in both the Insert and Update template in the parent formview. How do place the formview in the templates without...
4
by: =?Utf-8?B?ZGNoMw==?= | last post by:
Is there a way to conditionally format a dateTime field to produce on result if the value is 10/31/2008 12:00 AM (user didn't enter a time) and another result if the value is 10/31/2008 5:30 PM...
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: 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
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
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...
0
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,...

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.