Got an asp.net data-repeater on my page.
I can view the texts from the database (ex.: <%#
Databinder.Eval (Container.Data Item, "contentEN" ) %> ), but I also would like
to see the image, but only if there is one.
So in the repeater there should be someting like:
if ( the_image_field <> "" ) then
show the image with the filename from the database field
end if
THX ! 4 9563
In fact the problem can be reduced to:
How to use an if statement in a repeater control ??
THX
"nicholas" <mu********@hot mail.com> wrote in message
news:OG******** ******@TK2MSFTN GP15.phx.gbl... Got an asp.net data-repeater on my page. I can view the texts from the database (ex.: <%# Databinder.Eval (Container.Data Item, "contentEN" ) %> ), but I also would
like to see the image, but only if there is one.
So in the repeater there should be someting like:
if ( the_image_field <> "" ) then show the image with the filename from the database field end if
THX !
You will need to handle the ItemDataBound event to do this. I would go
ahead and place an image control in the repeater and bind it to the field
you use to determine the path to the image. Then in the ItemDataBound
event, you can do something like the following:
void repeater_ItemDa taBound(object sender, RepeaterItemEve ntArgs e)
{
Image myImage = e.Item.FindCont rol("myImage"); //This should be the
name of the Image control
if (myImage.ImageU rl == string.empty) // ImageUrl would be the field we
bound
myImage.Visible = false;
}
--
Ben Lucas
Lead Developer
Solien Technology, Inc. www.solien.com
"nicholas" <mu********@hot mail.com> wrote in message
news:e7******** ********@TK2MSF TNGP10.phx.gbl. .. In fact the problem can be reduced to: How to use an if statement in a repeater control ??
THX
"nicholas" <mu********@hot mail.com> wrote in message news:OG******** ******@TK2MSFTN GP15.phx.gbl... Got an asp.net data-repeater on my page. I can view the texts from the database (ex.: <%# Databinder.Eval (Container.Data Item, "contentEN" ) %> ), but I also would like to see the image, but only if there is one.
So in the repeater there should be someting like:
if ( the_image_field <> "" ) then show the image with the filename from the database field end if
THX !
Hi nicholas:
In addition to the ItemDataBound event, which is a great suggestion
Ben mentioned, there are ways to use methods inside of data binding
expressions. You can use just about anything there once you realize
how ASP.NET uses the expression when it gens code.
I think my article provides some insight:
Digging into DataBinding Expressions http://odetocode.com/Articles/278.aspx
HTH,
--
Scott http://www.OdeToCode.com/blogs/scott/
On Wed, 27 Oct 2004 15:35:13 +0200, "nicholas"
<mu********@hot mail.com> wrote: In fact the problem can be reduced to: How to use an if statement in a repeater control ??
THX
THX everyone for advice.
Here is my working code:
Serverside script:
-----------------
Function imageExists(ima gefield as String) as String
If (imagefield) <> "" then
Return "<img name=""image1"" src=""/files/file1/" & imagefield & """
alt="""" />"
Else
End If
End Function
And in my HTML:
------------------
<%# imageExists(Dat abinder.Eval(Co ntainer.DataIte m, "contentfile1") )%>
THX again.
Ciao
"nicholas" <mu********@hot mail.com> wrote in message
news:e7******** ********@TK2MSF TNGP10.phx.gbl. .. In fact the problem can be reduced to: How to use an if statement in a repeater control ??
THX
"nicholas" <mu********@hot mail.com> wrote in message news:OG******** ******@TK2MSFTN GP15.phx.gbl... Got an asp.net data-repeater on my page. I can view the texts from the database (ex.: <%# Databinder.Eval (Container.Data Item, "contentEN" ) %> ), but I also would like to see the image, but only if there is one.
So in the repeater there should be someting like:
if ( the_image_field <> "" ) then show the image with the filename from the database field end if
THX !
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Matthew Law |
last post by:
Hi,
I have a repeater in my vb.net page which needs to render an image
control (it's a mappoint linedrive map image). The repeater itself is
bound to an array of object 'Directions' which contains mostly
strings, but one of the Properties of the Direction Class is an image
of type System.Web.UI.WebControls.Image.
Obviously, if I try to render it in the repeater with the same
technique used for a string:
|
by: Joe via DotNetMonster.com |
last post by:
Hi,
I'm not sure how to get the image name from the database into the HTML img
tag. I can get regular text. For the img tag, this is what I have:
<img src="../images/<ASP:Repeater id="RepeaterMediaName" runat="server"
DataSource="<%# GetImage(MediaName) %>"><ItemTemplate><%# DataBinder.Eval
(Container.DataItem, "MediaName") %></ItemTemplate></ASP:Repeater>"
border="0" />
|
by: Jim via DotNetMonster.com |
last post by:
Hi,
I have the location of an image in the database and I'm displaying it with
a repeater control. I'd like to add the width and height and I'm not sure
what the best way to do it is. I could add the fields to the database and
lookup the size and enter it. I know with .Net there's a way to find out
the size but I'm not sure how to go about doing it. This is the repeater
control:
<ASP:Repeater id="RepeaterMediaName" runat="server"...
|
by: Rudy |
last post by:
Hello all!
I been trying to get a handle with Images. I have learned alot from the fine
people here. So, I also learned that thumbnail images look terrible taken
from a digital cam. I know why they look bad. So what is the best way to
resize an image. I'm not too concerned about size, but I guess I would like
to compress it on the upload.
Any thoughts?
|
by: mc |
last post by:
Scenario:
I have a database of companys, and a directory of images, each image has
the name of one of the companys, although not all companys have images.
I want a page which displays the details for each of the companys, so
far I'm using a repeater with labels for each of the address lines,
phone numbers, etc.
Problem:
| |
by: Bill44077 |
last post by:
Hi,
I am new to the MVP pattern and one of the main reasons that we are going
this route is because we are doing Scrum with 30 day sprints - so we have a
continually morphing design. We are using TDD as well to improve our ability
to refactor... you probably all know this approach.
Although the user iterface is supposedly one of the last things that you
need to do, this is a web app and we have multiple nested Repeaters on the
page....
|
by: Iain |
last post by:
Hi
I am using Borland Developer 2006, C# web application. Fairly new to
the .net platform and very new to repeaters.
I have 2 repeaters on a page, both of which are filled from a
database. The Links in the left hand column are created correctly and
displayed. The images/Links (hrefs) in the right hand column are the
problem. The links are displayed correctly but the images are not
displayed. The html is build dynamically. I have...
|
by: Sully |
last post by:
Hi Guys,
I have this about 98% done and I cannot get it work properly. I have a
Repeater bound to a MySQL DataSource, inside the Repeater I have an
ImageButton, outside the repeater I have a Image, code is below:
<asp:Image ID="imgLarge" Name="imgLarge" runat="server"
AlternateText="Large Custom Image" Height="300" Width="400" />
<asp:Repeater ID="rptSmall" runat="server"
OnItemDataBound="rptSmall_ItemDataBound1">
|
by: jollyguy77 |
last post by:
Hi,
I have just started to learn in .net. I want to show a list of filename along with the corresponding image (like pdf image for pdf files etc..). i will be getting the list of files from database. I want to show the files in list view format and also give the option for the user to change the view to details or thumbnail or icons accordingly.. also to give the option for renaming or deleting a file. I know that there is a Listview...
|
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...
|
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,...
| |
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...
|
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...
|
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...
|
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...
|
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();...
|
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...
| |
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...
| |