图像内容在SQLServer数据库里。读出来式byte[]形式的。我不想在服务器上生成图像文件,因为每个客户的图像是不一样的。只是希望在客户端那里出现图像。一本书上写的bete2里面可以用dynamicimage控件,可是在正式版没有找到。另外还有人说用HttpHandler()函数。也不会用。据说可以使用一个类似HTTP请求的形式?xxx=888的形式出来。应该怎么弄?

解决方案 »

  1.   

    新建一个页面 img.aspx
    在img.aspx 中把图象读出来
    在你要显示的页面中
    <img src=img.aspx> 就可以了
      

  2.   

    从SQL Server数据库提取图片并显示在DataGrid
    建立一个页面来读数据库的图片 如ReadPic.aspx
     string picID = Request.QueryString["id"];
       SqlConnection myConnection = new SqlConnection("Data Source=.;database=ImageDB;User Id=sa;Password=sa;");
       SqlCommand myCommand = new SqlCommand("Select  Pic from Person Where ID=" 
        + picID, myConnection);   try
       {
        myConnection.Open();
        SqlDataReader myDataReader;
        myDataReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);
        if(myDataReader.Read())
        {
         Response.ContentType = myDataReader["PersonImageType"].ToString();
         Response.BinaryWrite((byte[])myDataReader["PersonImage"]);
        }
        myConnection.Close();
       }
    然后在datagrid的aspx页面如 DataGridPic.aspx放置模板列
    <ItemTemplate>
            <asp:Image Runat=server ID="Image1"
             ImageUrl='<%# DataBinder.Eval(Container.DataItem, "ID") %>' />
          </ItemTemplate>
    就可以了
      

  3.   

    response.outputstream 字节数组 也可以。