从Oracle数据库在asp.net中的“图像和网格"视图中显示图像 [英] Displaying Image in Image and Grid view in asp.net from Oracle database

查看:72
本文介绍了从Oracle数据库在asp.net中的“图像和网格"视图中显示图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,
我只想在图像中显示我的图像

Dear,
I want to just show my Image in Image

protected void btnLoad_Click(object sender, EventArgs e)
       {
           string connstr = System.Configuration.ConfigurationManager.ConnectionStrings["oracleConString"].ToString();

          OracleConnection con = new OracleConnection(connstr);
          OracleCommand cmd = new OracleCommand("SELECT PICPHOTO FROM picTest WHERE PICID = 4", con);
           con.Open();
           byte[] img = (byte[])cmd.ExecuteScalar();
           con.Close();
           picImageT.ImageUrl =""+CreateFile(img)+"" ;

          /* foreach (GridViewRow hgrow in GridView1.Rows)
           {
               Image picImage = (Image)hgrow.FindControl("Image1");

               //picImage.ImageUrl=Response.BinaryWrite(img);
               //picImage.ImageUrl = CreateFile(img);

               picImage.ImageUrl = CreateFile(img);
           }*/

       }



方法



Method

private string CreateFile(byte[] img)
       {

           string sPath = string.Empty;
           sPath = "C:\\test4.jpeg";
           //File.Create(sPath);

           using (BinaryWriter binwriter = new BinaryWriter(File.Open(sPath, FileMode.Create)))
           {
               binwriter.Write(img);
           }
           return sPath;
       }



现在它什么也没有出现,如果有人知道如何在图像中实现它,然后再使用网格视图进行显示,我在这里几乎没有关于网格视图的代码.请提前帮助我
马哈茂德
Software Engineer



Now it doesn''t appear anything,if any one know how to implement it in image and then as well display using grid view I have little bit code here about grid view.Please help me thanks in advance
Mahmud
Software Engineer

推荐答案

大约可以,如果我对您的理解正确的话
Approximately so, if I have understood you correctly
private System.Windows.Forms.DataGridViewImageColumn colPicture;
......
colPicture.ImageLayout = System.Windows.Forms.DataGridViewImageCellLayout.Zoom;
........
DataGridView[colPicture.Name, index].Value = Files.getImageFromBinary(byte[] img);


这篇关于从Oracle数据库在asp.net中的“图像和网格"视图中显示图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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