我已经搜索过,但找不到正确的答案。请参阅下面的代码并告诉我该怎么做。我的图像框的名称是 picbox 提前致谢
try
{
int w = Convert.ToInt32(RegID.Text);
byte[] image = null;
{
var photoRecord = (from accom in re.Students
where accom.RegistrationNo == w
select accom).First();
image = photoRecord.Picture;
}
}
catch (Exception)
{
throw;
}
最佳答案
我只添加了两行,它必须完美工作
try
{
int w = Convert.ToInt32(RegID.Text);
byte[] image = null;
{
var photoRecord = (from accom in re.Students
where accom.RegistrationNo == w
select accom).First();
image = photoRecord.Picture;
string base64String = Convert.ToBase64String(image, 0, image.Length);
picbox.ImageUrl = "data:image/png;base64," + base64String;
}
}
catch (Exception)
{
throw;
}
关于c# - 如何使用 Entity Framework 将二进制图像从数据库加载到asp.net(无MVC)中的imagebox.imageurl,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29125844/