我通过imageurl="showphoto.aspx?id="+id,能正常显示,但图片变形了,怎么在我的基础上缩略显示
showphoto.aspx:如下
private void Page_Load(object sender, System.EventArgs e)
{
string id=Request.QueryString["Id"].ToString();


string sql="SELECT * FROM Product WHERE ID = " + id;


System.Configuration.AppSettingsReader configurationAppSettings = new System.Configuration.AppSettingsReader();
System.Data.SqlClient.SqlConnection sqlConnection = new System.Data.SqlClient.SqlConnection();
sqlConnection.ConnectionString = ((string)(configurationAppSettings.GetValue("ConnectionString", typeof(string))));
SqlCommand command = new SqlCommand(sql,sqlConnection);
sqlConnection.Open();
SqlDataReader dr = command.ExecuteReader();
if(dr.Read())
{
Response.Clear();
Response.AddHeader("Content-Type",dr["pFileType"].ToString());
Response.BinaryWrite((byte[])dr["Picture"]);
}
dr.Close();
sqlConnection.Close()

解决方案 »

  1.   

    你这样试试,你强制限制IMAGE控件的高度和宽度来限制图片显示的大小,你试试
      

  2.   

    你可以这样试试,你强制限制IMAGE控件的高度和宽度 以此来限制图片的显示的大小,你试下
      

  3.   

    public string ResizeBitmap(string strFileName,int nWidth,int nHeight,int maxWidth)
    {  
    //将原始图片缩放为指定大小的图片
    System.Drawing.Bitmap b = new System.Drawing.Bitmap(Server.MapPath(strFileName));
    if(b.Width > maxWidth)
    {
    if(nHeight < 1) nHeight = b.Height; Bitmap result = new Bitmap(nWidth,nHeight);  
    Graphics g = Graphics.FromImage((System.Drawing.Image)result);
    g.DrawImage(b,0,0,nWidth,nHeight);  

    int index=strFileName.LastIndexOf("/");
    string strForeside="";
    if(index>0) strForeside=strFileName.Substring(0,index+1);
    strFileName = strForeside+"Temp"+strFileName.Substring(strFileName.Length-4); result.Save(Server.MapPath(strFileName)); result.Dispose();
    g.Dispose();
    }
    b.Dispose(); return strFileName;
    }
      

  4.   

    <ItemTemplate>
    <asp:Image id=Image3 runat="server" ImageUrl='<%#DataBinder.Eval(Container, "DataItem.字段名")%>'</asp:Image></ItemTemplate>
      

  5.   

    "DataItem.字段名")%>'后面少了个>补上保证可以.
      

  6.   

    2005-01-24 09:32:24 ?????
    这么久的帖子都给翻了出来, hoho