显示我的数据库表中的所有图像的问题不会显示在我的webform上 [英] probleme with showing all images from table of my database are not displayed on my webform
本文介绍了显示我的数据库表中的所有图像的问题不会显示在我的webform上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我试图显示他时,我的数据库表中的图像不显示
i不知道这里的问题在哪里:
My images from table of my database are not displayed when i try to display him
i don't know where is the probleme here :
cmd = new SqlCommand("select * From Car", Connection.cnx);
Connection.OpenCnx();
rdr = cmd.ExecuteReader();
int i=0;
while (rdr.Read())
{
i++;
byte[] imgBytes = (byte[])rdr["Imagecar"];
System.Web.UI.WebControls.Image image = new System.Web.UI.WebControls.Image();
image.ID = Convert.ToString(i);
image.ImageUrl = "data:image/jpg;base64," + Convert.ToBase64String(imgBytes);
image.Height = 225;
image.Width = 224;
}
rdr.Close();
}
我没有留言错误
and i haven't message error
推荐答案
所有浏览器都不支持数据URI(base64格式),并且还有一些大小限制。您是否也在其他浏览器中查看过它?
Data URI (base64 format) is not supported in all the browsers and also there is some size limit. Did you check it in other browsers as well?
我找到了一个使用HttpHandler的链接。它适用于在图像控制或GridView中显示图像。
http://www.aspdotnetcodes.com/Insert_Images_Database.aspx [ ^ ]
另外你可以使用 Image.FromStream()方法编写一段代码,从二进制流创建一个图像对象并放在你的方法中。
I found a link for you using HttpHandler. It works well in displaying images either in image control or in GridView.
http://www.aspdotnetcodes.com/Insert_Images_Database.aspx[^]
Also you can write a piece of code using Image.FromStream() method to create an image object from binary stream and place inside your method.
这篇关于显示我的数据库表中的所有图像的问题不会显示在我的webform上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文