?
Solved

gridview Imagefield url

Posted on 2007-11-30
5
Medium Priority
?
1,514 Views
Last Modified: 2010-10-05
I have an access database when I store images path ("Percorso") titles and descriptions

I am trying to display it with a gridview.

however I can get everything but the imagefield url in the codeview of my browser is empty

<td><a href="javascript:__doPostBack('ctl00$ContentPlaceHolder1$GridView1','Delete$0')">Delete</a></td><td>199</td><td>
<img src="" style="border-width:0px;" /></td>
<td>People</td>
<td>C:\Users\massimobrillante\Desktop\Websites\MarlonCommunications\public\photography\people\Fab110_05_06.jpg</td>
<td>no titolo</td><td>no descrizione</td><td>30/11/2007 0.00.00</td>

however the "Percorso" field (the path) that I am showing into the gridview for test is correctly filled  with the images URL. Below the gridview code as you can see from the above browser source code

why the image src is empty ?? when the server side code is displayed ??
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
        DataKeyNames="PhotoId" DataSourceID="ObjectDataSourcePhotos">
        <Columns>
            <asp:CommandField ShowDeleteButton="True" />
            <asp:BoundField DataField="PhotoId" HeaderText="PhotoId" InsertVisible="False"
                ReadOnly="True" SortExpression="PhotoId" />
            <asp:ImageField DataImageUrlField="Percorso" HeaderText="Photo" />      
            <asp:BoundField DataField="Categoria" HeaderText="Categoria" SortExpression="Categoria" />
            <asp:BoundField DataField="Percorso" HeaderText="Percorso" SortExpression="Percorso" />
            <asp:BoundField DataField="Titolo" HeaderText="Titolo" SortExpression="Titolo" />
            <asp:BoundField DataField="Descrizione" HeaderText="Descrizione" SortExpression="Descrizione" />
            <asp:BoundField DataField="PhotoDate" HeaderText="PhotoDate" SortExpression="PhotoDate" />
        </Columns>
    </asp:GridView>

Open in new window

0
Comment
Question by:brillox
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 16

Accepted Solution

by:
anoyes earned 2000 total points
ID: 20385826
If you look at the image path that is being produced, it's a local path (i.e. it's pointing to your C:\ drive).  This won't work on a website.  How is the path being stored in your database?  Is what is shown above (C:\Users\massimobrillante\Desktop\Websites\MarlonCommunications\public\photography\people\Fab110_05_06.jpg) the way it's stored in the DB?  The path that's in the database should be stored as a path that is relative to the root of your website.  So if you website www.website.com lives at C:\Users\massimobrillante\Desktop\Websites\MarlonCommunications\public\, then the path for the image stored in the DB should only be /photography/people/Fab110_05_06.jpg.  Note the "/" at the beginning - this tells the server that to start working from the root of the website.  Then your image (on the web) lives at www.website.com/photography/people/Fab110_05_06.jpg.  Does this make sense / solve your problem?
0
 

Author Comment

by:brillox
ID: 20386061
Yes you are right and I need a course in path :)

I am njow storing the image path as this ../imagepath and it works fine.
just to double check.. it will work also once online ? i guess it will.

0
 

Author Comment

by:brillox
ID: 20386074
I have the images stored in different subfolders as the owner of the website wnat to categorize all the images. so a path will be like http://www.mywebsite/public/category/image.jpg

so the http://www.mywebsite/public is always the same, is the path after this that changes

infact in the above post, ../imagepath is equal to
/public/category/imagename.extention
0
 
LVL 16

Expert Comment

by:anoyes
ID: 20386343
Yes it will work once posted online as well.  That's the great thing about relative paths.
0
 

Expert Comment

by:gbarje1
ID: 23534775
how can we display images if they are not stored within the working folder but on a totally different location on the server
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question