0

Building a website with 571 houses, each house has a image associated with it. I want to set a virtual path in the database to a folder containing 571 images. There is 571 rows in the database with a few columns one of them being image I want to set the path in this column and then retrieve the image for each house on the aspx page.

I think I display the image like this

<asp:Image ID="img1" runat="server"
    ImageUrl='<%#Eval("path") %>'>
</asp:Image>

but I am not to sure how to set the path to the folder in the database.

Database Structure

enter image description here

ASPX Page

enter image description here

1 Answer 1

1

You can use String.Format for this as detailed below

ImageUrl='<%# String.Format("~/YOUR_IMAGE_FOLDER/{0}", Eval("path"))%>'

Just replace your ImageUrl as above.

Sign up to request clarification or add additional context in comments.

2 Comments

the folder is stored on a drive not in the project
You can give virtual path or web path for that folder

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.