Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

gridview Imagefield url

Posted on 2007-11-30
5
Medium Priority
?
1,520 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
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…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

618 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