关键代码
int iLeft = (j % 3) * 360; string strLeft = iLeft.ToString(); int iLeft0 = iLeft + 10; string strLeft0 = iLeft0.ToString(); string HImage ="70"; int iTop = row * 70; int iTopImage = iTop - 20; string strTop = iTop.ToString(); string strTopImage = iTopImage.ToString(); Image image = new Image(); image.ImageUrl = "Common/ShowImage.aspx?id=" + dt.Rows[i][3].ToString(); //获取签名 image.CssClass = "tmd"; image.Style.Add(HtmlTextWriterStyle.Left, iLeft0 + "px"); image.Style.Add(HtmlTextWriterStyle.Top, strTopImage + "px"); image.Style.Add(HtmlTextWriterStyle.Height, HImage + "px"); this.Controls.Add(image);
ShowImage.aspx
using System; using System.Data.OracleClient; using System.Web.UI; public partial class NewFrameWorkUI_Physician_Common_ShowImage : System.Web.UI.Page { string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionStringOracle10"].ToString(); protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { ShowData(); } } public void ShowData() { object s = Request.QueryString["id"]; string strSQL = "select emp_no,name,signature from staff_dict where id='" + s.ToString() + "'"; OracleConnection connection = new OracleConnection(connectionString); OracleCommand cmd = new OracleCommand(strSQL, connection); try { connection.Open(); OracleDataReader myReader = cmd.ExecuteReader(); if (myReader.Read()) { if (myReader["signature"] is DBNull) return; Response.Clear(); Response.ContentType = "application/binary;"; Response.BinaryWrite((byte[])myReader["signature"]); Response.Flush(); Response.End(); } } catch (System.Data.OracleClient.OracleException E) { throw new Exception(E.Message); } } }