[英]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 reader = comm.ExecuteReader())
{
Byte[] images = new Byte[]();
while (reader.Read())
{
Response.BinaryWrite(images);
}
}
and in the aspx file i have: 在aspx文件中,我有:
<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. 我认为最好的方法是不使用数据库并将图像存储在磁盘上-通过以二进制形式将图像存储在db列中,您就受到了限制。
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. 如果您真的打算以这种方式存储图像,那么我只能建议从数据库加载所需的所有图像,然后将它们写入磁盘上的临时文件夹,然后显示引用其
<img />
的<img />
标记列表服务器上的临时位置。
All you do then is every time the images are requested you delete the ones from the previous request. 您要做的就是每次请求图像时都从上一个请求中删除图像。
您需要制作一个按ID提供单个图像的页面,然后添加多个<img>
标记,这些标记在查询字符串中引用具有不同ID的页面。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.