Solved

gridview Imagefield url

Posted on 2007-11-30
5
1,476 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
  • 2
  • 2
5 Comments
 
LVL 16

Accepted Solution

by:
anoyes earned 500 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

744 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now