Click here to Skip to main content
15,893,722 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
<asp:TemplateField HeaderText="Image">
    <ItemTemplate>
        <asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("imagepath") %>' Height="100px"
                   Width="100px" />
    </ItemTemplate>
</asp:TemplateField>



XML
Thanks for your edit!
    This edit will be visible only to you until it is peer reviewed.

<asp:TemplateField HeaderText="Image">
    <ItemTemplate>
        <asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("imagepath") %>' Height="100px"
                   Width="100px" />
    </ItemTemplate>
</asp:TemplateField>

The path which is binding is C:/inetpub/wwwroot/Image/FolderName/abc.jpg from a table, but it is not getting displayed. The image is in the same folder and it is not even giving any exception.

Is it necessary to save image in a folder inside application/Project folder? If saved outside in any other path/directory does that image doesn't save properly or gives problem in fetching?

I am stuck. Please Help Me.
Posted
Comments
What path you see in HTML source rendered?
F-ES Sitecore 2-May-15 8:25am    
If the image is on your server then what you need to store in the database is "/foldername/abc.jpg" as that is the path to the file relative to the site root. When it is rendered as an img tag the browser will request the file from your server as http://yourserver/foldername/abc.jpg.

If you store the path to the file on the server's disk this means nothing to the client, that is a file reference relative to your server and doesn't allow the client browser to access the file.
PWAVEL 2-May-15 8:30am    
"C:/inetpub/wwwroot/Image/FolderName/abc.jpg" is the path i see in HTML source rendered.Currently i am running my project localy.image and project both on same system.but image is present in another folder not inside projects folder.and i want to display image from this path only C:/inetpub/wwwroot/Image/FolderName/abc.jpg.This abc.jpg path is stored in database."C:/inetpub/wwwroot/Image/" i concatenate in sp with abc.jpg and assign to image url.
Then this might be a security issue. See if the folder is accessible or not. Go to folder properties and assign proper rights.
PWAVEL 2-May-15 8:51am    
i have full control over image folder.do i need to assign permissions to inetpub or wwwroot folder or just to image folder?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900