如何将二进制数据图像从数据库表绑定到Gridview和ListView [英] how to bind binary data images from database table to Gridview and listview

查看:111
本文介绍了如何将二进制数据图像从数据库表绑定到Gridview和ListView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将二进制图像从数据库绑定到GridView和ListView.我有2列的数据库表(ImageID(数据类型:int),Image(数据类型:Image))

有任何想法吗?

I need to bind binary images to GridView and ListView from database. I have database table with 2 columns ( ImageID (data type: int), Image(data type: Image))

Any Idea?

推荐答案

您尝试过这个吗?!
使用C#在ASP.NET中从DB获取GridViewImages [
Did you try this?!
GridViewImages from DB in ASP.NET using C#[^]


选中此链接,它将为您提供帮助
在ASP.NET中进行图像处理 [
check this link, it will help you
Image Handling In ASP.NET[^]


int NewsId = Int16.Parse(Request.QueryString ["id"]);
DataTable dt = new DataTable();
dt = obj.GetNewsById(Operation,NewsId);
byte [] data =(byte [])obj.GetNewsById(Operation,NewsId).Rows [0] ["photo"];
if(数据!= null)
{
Byte [] bytImage =(data);
如果(bytImage!= null && bytImage.Length!= 0)
{
Response.ContentType ="image/jpeg";
Response.Expires = 0;
Response.Buffer = true;
Response.Clear();
Response.BinaryWrite(bytImage);
Response.End();
}
}
int NewsId = Int16.Parse(Request.QueryString["id"]);
DataTable dt = new DataTable();
dt = obj.GetNewsById(Operation, NewsId);
byte[] data =(byte[])obj.GetNewsById(Operation,NewsId).Rows[0]["photo"];
if (data != null)
{
Byte[] bytImage = (data);
if (bytImage != null && bytImage.Length != 0)
{
Response.ContentType = "image/jpeg";
Response.Expires = 0;
Response.Buffer = true;
Response.Clear();
Response.BinaryWrite(bytImage);
Response.End();
}
}


这篇关于如何将二进制数据图像从数据库表绑定到Gridview和ListView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆