Reputation: 35
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
Upvotes: 1
Views: 5034
Reputation: 14314
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.
Upvotes: 2
Reputation: 887415
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.
Upvotes: 1