Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 1.0 and 1.1 > ASP.NET 1.0 and 1.1 Professional
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 5th, 2007, 01:49 AM
Registered User
 
Join Date: Jan 2007
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to jasdeephere
Default How to display images dynamically into datalist

hiiiiiiii
I am developing a shopping cart project. On my home page i want to display data into datalist control alongwith their images.
the data is coming form two tables!!
in first table i have all the details of an item and in another table i have the images for that items.
I am using joins to get the data from both the tables and it works fine.
but my problem is when i bind that data with the datalist control i have to show the images of every items respective to that item but i am unable to do that.
If i give src of image control in datalist to a particular path alongwith the particular image name then it is ok suppose

<asp:Image ID="img" src = '/test/images/sample.jpg' Runat="server">
</asp:Image>
It works fine

but i want to pass src in this way that it could display not a particular image for all items but respective images for all items.

Hope you got my problem and will reply me very soon

One more thing the image has been stored into one folder name"images" and path has been stored to the database.

Please give some replies for this. Its very urgent for me.
Please Please Please!!!!!!!!!

Thanx & Regards
Jasdeep Singh


 
Old February 5th, 2007, 01:34 PM
Friend of Wrox
 
Join Date: Jul 2003
Posts: 599
Thanks: 6
Thanked 3 Times in 3 Posts
Default

Is the image name and path in the database? I use a file uploader when uploading images to sites and use the database ID column as the name of the image. Then I can retrieve the image just by using the database ID as below.

SELECT '<img src=/images/compdef/' + CONVERT(varchar,CompDefID) + '.gif height=16 width=16 border=0>' AS CompDefImage FROM [Table]

You could also do this within the itemtemplate of a repeater:

<img border="0" src="/images/compdef/<%#DataBinder.Eval(Container.DataItem,"CompDefID") %>.gif" width="24" height="24" align="absmiddle" alt="<%#DataBinder.Eval(Container.DataItem,"CompAl iasName")%>" />

Substitute your image names and paths.

Good luck!

 
Old February 7th, 2007, 06:14 AM
Registered User
 
Join Date: Feb 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

O think the way this images are kept matter. Is it that the only ID is stored in the image column or the ID is also used to save the image in the physical folder. If it is, then
try this out

Select ID from <<database>> where <<criteria>>

In the datalist,
<asp:Image src='<%# Eval("ID","/test/images/{0}.gif")%>' width="" height="" runat="server"></asp:image>

Does it work?






Similar Threads
Thread Thread Starter Forum Replies Last Post
datalist display almotions ASP.NET 2.0 Basics 1 February 18th, 2008 03:19 AM
How To Display Images in DataList abdul_owiusa General .NET 4 June 3rd, 2005 11:49 AM
How To Display Images in DataList abdul_owiusa General .NET 1 May 20th, 2005 09:01 AM
Display images dynamically based on links stored khalidone Crystal Reports 4 September 22nd, 2004 02:26 PM
datalist and images(get width and height) collie VB.NET 2002/2003 Basics 1 August 4th, 2004 08:24 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.