在一个页面中如何显示多张图片???
有两个页面:
其一:displaynews.aspx包括一
<asp:image id="picture" Runat="server" Visible="False"></asp:image>控件,
在其cs文件中:
//显示图片(参数:display,1 true 0 false)
SqlDataReader dr = news.GetNewsAttach(NewsID,1);
//if(dr.Read()),当用if时显示第一张图片,当用while显示最后一张图片
while(dr.Read())
{
picture.ImageUrl= "Display.aspx?AttachID="+dr["Attach_ID"].ToString();
picture.Visible = true;
}
另一页面用于显示图片,为dispay.aspx其cs文件为:
if(Request.Params["AttachID"] != null)
{
string strSQL = "SELECT * FROM News_Attach WHERE Attach_ID = "+Request.Params["AttachID"];
SqlCommand myComm = new SqlCommand(strSQL,myConn);
myConn.Open();
SqlDataReader dr = myComm.ExecuteReader();
if(dr.Read())
{
Response.ContentType = dr["ContentType"].ToString(); System.Drawing.Image _image=System.Drawing.Image.FromStream( new System.IO.MemoryStream( (byte[])dr["UpFiles"] ));
if (_image.Width > 450)
{
Int32 _width = 450;
Int32 _height = Convert.ToInt32( _image.Height * ( 450.00 / _image.Width));
Bitmap _ResizedBmp = new Bitmap(_image,_width,_height);
_ResizedBmp.Save(System.Web.HttpContext.Current.Response.OutputStream,_image.RawFormat);
_ResizedBmp.Dispose();
_image.Dispose();
}
else
{
Response.OutputStream.Write((byte[])dr["UpFiles"], 0, (int)dr["ByteSize"]);
_image.Dispose();
}
}
请问如何显示多张图片