1

i am creating a page that will display multiple images from the database... i can do it if i will only display one image, by using a page to be rendered as image.. something like this...

using (SqlDataReader reader = comm.ExecuteReader())
{
    Byte[] images = new Byte[]();
    while (reader.Read())
    {
         Response.BinaryWrite(images);
    }
}

and in the aspx file i have:

<asp:Image ID="imgPhoto" runat="server" ImageUrl="~/ShowImages/LoadImages.aspx" Height="100px" Width="100px" BorderWidth="1px" />

what i want to achieve is to display multiple images from the database without making a page to be rendered as image...

is there any way to work around with this... ?

thanks guys

2 Answers 2

2

I think the best way would be not using a database and storing the images on the disk - by storing images in binary form in a db column in this way you are limiting yourself.

If you are really set on storing images in this way then I could only suggest loading all the images you want from the db, and writing them to a temporary folder on the disk, then displaying a list of <img /> tags that reference their temporary location on the server.

All you do then is every time the images are requested you delete the ones from the previous request.

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

1 Comment

Have a look at the .NET File class in System.IO, it allows easy creation /deletion of files, also look at the Directory class in the same namespace, which provides similar functionality for folders. If you google "Byte array to file" you will find loads of info on how to do it.
1

You need to make a page that serves a single image by ID, then add multiple <img> tags that reference that page with different IDs in the querystring.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.