473,378 Members | 1,393 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,378 software developers and data experts.

problem using Image control in DataList

Hi

I am using Image control with DataList control but have a problem. Here is the code I am using

<asp:Image ImageURL='<%# DataBinder.Eval(Container.DataItem, "imagefilename" ) %>' Runat="Server" /

I would like to change it to something like this

<asp:Image ImageURL='images/<%# DataBinder.Eval(Container.DataItem, "imagefilename" ) %>' Runat="Server" /

In other words, I would like to add a folder name part to the ImageURL value. However it doesn't seem to work properly. What should I do

Thank you in advance

Vitalii
Nov 18 '05 #1
3 5838
Try concatenating images/ with the Eval.

Not sure if you just need

&

or

&amp;
--
Joe Fallon

"Vitalii" <vi******@gol.com> wrote in message
news:33**********************************@microsof t.com...
Hi,

I am using Image control with DataList control but have a problem. Here is the code I am using:
<asp:Image ImageURL='<%# DataBinder.Eval(Container.DataItem, "imagefilename" ) %>' Runat="Server" />
I would like to change it to something like this:

<asp:Image ImageURL='images/<%# DataBinder.Eval(Container.DataItem, "imagefilename" ) %>' Runat="Server" />
In other words, I would like to add a folder name part to the ImageURL value. However it doesn't seem to work properly. What should I do?
Thank you in advance,

Vitalii

Nov 18 '05 #2
Vitalii

Create a function in the code behind and call it from the databinding. It
will look like this:

'---Code behind function:
Public Function GetImagePath(ByVal imageFileName As String) As String
Return "images/" & imageFileName
End Function

Then on the calling page call this function passing in the data:
<asp:Image ImageURL='<%# GetImagePath(DataBinder.Eval(Container.DataItem,
"imagefilename" )) %>' Runat="Server" />

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Vitalii" <vi******@gol.com> wrote in message
news:33**********************************@microsof t.com...
Hi,

I am using Image control with DataList control but have a problem. Here is the code I am using:
<asp:Image ImageURL='<%# DataBinder.Eval(Container.DataItem, "imagefilename" ) %>' Runat="Server" />
I would like to change it to something like this:

<asp:Image ImageURL='images/<%# DataBinder.Eval(Container.DataItem, "imagefilename" ) %>' Runat="Server" />
In other words, I would like to add a folder name part to the ImageURL value. However it doesn't seem to work properly. What should I do?
Thank you in advance,

Vitalii

Nov 18 '05 #3
hi try this on
<%#Server.MapPath(@"\images"+DataBinder.Eval(Conta iner.DataItem, "imagefilename")%>
Nov 18 '05 #4

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

Similar topics

2
by: Vitalii | last post by:
Hi I am using Image control with DataList control but have a problem. Here is the code I am using <asp:Image ImageURL='<%# DataBinder.Eval(Container.DataItem, "imagefilename" ) %>'...
2
by: Manish Naik | last post by:
Hi, Using ASP.Net, I want to store and retrive documents (Word, excel, etc) from SQL Server 2000 database. I have tried image type data field, but could not succed. Can any one help me please. ...
1
by: Glenn Owens | last post by:
Here's the scenario: I have a DataList populated from a datatable sitting inside a fieldset. Each element (row) in the Datalist has the following child controls: asp:checkbox, asp:image,...
2
by: Olav Tollefsen | last post by:
I have a Web Form with a DataList. Inside the ItemTemplate, I have a DropDownList control. <asp:DataList ID="ProductDataList" Runat="server"> <ItemTemplate> <asp:DropDownList ID="DropDownList1"...
0
by: Larry | last post by:
I have a dataset with filenames for the image buttons for my datalist. The image files as in a directory "GallerySubmissions". The datalist is part of a user control. What I can not get to work...
2
by: Hans Merkl | last post by:
Hi, I am trying to use a user control as EditItemTemplate in a DataList. It loads fine but I can't figure out how to bind to the data of the DataList. Here is what I have got so far: ...
1
by: sck10 | last post by:
Hello, I have created a photo gallery of thumbnails using the code below. So far, I got the pictures to show, but now I need to figure out how a viewer can click on the thumbnail and it opens the...
0
by: Maran | last post by:
We have come across a situation that I thinks not many have. Grateful for all responses. Regards Maran ************* * Scenario A DataList binds to a DataRow, with "RegionName" och...
2
by: Charlie | last post by:
Hi: When using templated columns in DataList, ASP.net server controls can be inserted. Rather than using the base ASP.net server controls, I would like to use one of my own custom server...
1
by: Chris | last post by:
Hi, i created an ImageButton within an ItemTemplate of a datalist (in shop.aspx). There are two possibilities: 1) when the user is logged and he clicks on an image, he must be 'postbacked' to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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...

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.