Solved

gridview Imagefield url

Posted on 2007-11-30
5
1,497 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

679 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