开发者

display multiple images from database to asp.net page

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 re开发者_Python百科ader = 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


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜