我现在数据库里有Photo 类型是 Image  我做的添加页面的已经成功将其加入.现在我想再查看页面用Image控件  显示这个图片. 怎么实现啊?
Image 只有 ImageUrl或 Src 属性啊~~
我的查看页面有个页面传值id高手帮帮忙啊~小弟万分感谢
很着急 在线等

解决方案 »

  1.   

    Response.BinaryWrite(byte[])输出来。
    http://blog.csdn.net/striveman/archive/2006/11/09/1375942.aspx
      

  2.   

    怎样把sql_server数据库里的(类型是image)图片显示在aspx页面里的image控件里
    首先建一个显示图片的文件show.aspx,其中show.aspx.cs文件这样写:
    private void Page_Load(object sender, System.EventArgs e)
      {
       // 在此处放置用户代码以初始化页面
       SqlConnection conn = new SqlConnection(ConfigurationSettings.AppSettings["connstr"].ToString());
       conn.Open();
       string id = Request.QueryString["id"];
       DataSet ds = new DataSet();
       byte[] myData = new byte[0];
       SqlDataAdapter da = new SqlDataAdapter("select picture from tablename where id="+id,conn);
       da.Fill(ds,"product");
       DataRow myRow;
       myRow = ds.Tables["tablename"].Rows[0];
       if(myRow["picture"].ToString()!="")
        myData = (byte[])myRow["picture"];
       Response.ContentType ="jpg";
       Response.BinaryWrite( myData );
      }
    然后再在你要显示图片的文件上写:<img src="show.aspx?id=yourid">
    要显示图片的文件和show.aspx在相同路径下。
      

  3.   

    LZ就是要实现到数据库!里面 !!LS的你说呢?
      

  4.   

    <img src="<%=后台变量%>"/>