473,799 Members | 3,270 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2738

"Mike" <xx*@xxx.xxxwro te in message
news:uS******** *****@TK2MSFTNG P06.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
10276
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 directory within a Crystal Report. I created a typed dataset that is not bound to the database called dsLogo and created one field within it that has a base64binary type for the image. Once I've incorporated the dataset into the report and dropped the...
1
1175
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 No-Image "image" (a one pix gif). I get the values to displa fine by coding: ImageURL1.ImageUrl = myProductDetails.ImageURL1
3
2992
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 controls if my pages detected their login. Non-logged in users would also get some page content at a given URL, but the protected content was hidden from them. I would like to know generally how this is done in ASP.NET. I'm particularly...
0
938
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 user when in design view. Sometimes it might not initially display like this but a click on the right hand side handle of the control forces it to resize according to the width property. However, if I set the width to 100% I cannot get the...
4
1288
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 records. My question: What is the best way to display the product record with the respective image record(s)? Using a FormView for the product record and a GridView/DataList for the image record(s)? Or, writing own code (using Table, Row, Cells and...
1
3891
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 and a FormView on the same page, where the GridView is visible at page load, and the FormView is set to Edit mode by default, but is hidden on the page. I have the Select link enabled on my GridView, and I use the SelectedIndexChanged event to hide...
2
1307
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 of VS.NET 2003 I have 'Input -> Additional Dependencies' where I can add my .lib files the linker should use. How do I tell the linker (by a macro ?) somthing like this:
0
1130
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 copying the formview, something which is not very maintainable. i have tried creating a placeholder and adding the formview programatically but I get errors relating to the datasource. Does this need to be added programatically as well? Regards,...
4
3054
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 (user entered a time). I'm looking for this result... Value Result 10/31/2008 12:00 AM FRI 10/31/08 10/31/2008 12:01 AM FRI 10/31/08 12:01 AM I also need to figure out the cell spacing to force the time...
0
9688
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
10259
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...
1
10238
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10030
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7570
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
6809
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5589
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3761
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2941
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.