简体   繁体   English

从数据库显示多个图像到asp.net页面

[英]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.

相关问题 如何使用entityframework从sql数据库中使用asp.net动态显示多个图像 - how to dynamically display multiple images using asp.net from sql database using entityframework 在ASP.NET中显示数据库中的Null - Display Null from database in asp.net ASP.NET-从数据库中检索图像列表并将其显示在视图中? - ASP.NET -Retrieving a list of images from the Database and display them in the view? 从MySQL数据库检索具有固定尺寸的图像后,如何在ASP.NET中显示它们 - How to display images with fixed dimensions in ASP.NET after retrieving them from a MySQL database ASP.NET MVC从数据库显示多个图像。 如何高效 - ASP.NET MVC Displaying Multiple Images from Database. How to- Efficiently ASP.NET 核心在页面上显示数据库中的所有行 - ASP.NET Core display all rows in database on page 为什么我的页面在绑定并尝试显示数据库ASP.net中的数据后变为空白 - Why my page goes blank after binding and trying to display data from database ASP.net ASP.NET MVC-尝试显示从数据库中提取的图像\\ - Asp.net mvc - trying to display images pulled from db \ 从C#动态显示asp.net中的图像 - display images in asp.net dynamically from c# 使用Asp.net将图像从本地文件夹显示到数据列表 - Display images from local folder to datalist using Asp.net
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM