images in datalist in asp.net 1.1
-
Sir, I want to display the images in the datalist control images(landscape, portrait).The images can be of any size in the hard disk and finding the image size the image size in the datalist will be declared dynamically i.e for portrait and landscape the datalist control will have two image size also both the sizes will be fixed like for landscape the image size in the datalist will be 400*200 likewise for the portrait 200*400.The major problem that is occuring in declaring the image control in the datalist control at the run time.I also want to make some description for the image.the discription can be of any length. Can anybody please sort out this problem.Please send me project link if somebody have.I shall be highly obliged. Thanks and Regards Sandeep Thakur
-
Sir, I want to display the images in the datalist control images(landscape, portrait).The images can be of any size in the hard disk and finding the image size the image size in the datalist will be declared dynamically i.e for portrait and landscape the datalist control will have two image size also both the sizes will be fixed like for landscape the image size in the datalist will be 400*200 likewise for the portrait 200*400.The major problem that is occuring in declaring the image control in the datalist control at the run time.I also want to make some description for the image.the discription can be of any length. Can anybody please sort out this problem.Please send me project link if somebody have.I shall be highly obliged. Thanks and Regards Sandeep Thakur
Create a new aspx page( say image.aspx ) & write this code-- using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Drawing.Imaging; using System.IO; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Data.SqlClient; public partial class newhomesales_admin_imagedisplay : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string connectionString = System.Configuration.ConfigurationSettings.AppSettings["SqlNewHomeSalesRealty"].ToString(); System.Data.SqlClient.SqlConnection Con = new System.Data.SqlClient.SqlConnection(connectionString); string imgname = Request.QueryString["imgname"]; string modelid = Request.QueryString["modelid"]; System.String SqlCmd = "select " + imgname + " from model_new where modelid=" + modelid + ""; System.Data.SqlClient.SqlCommand SqlCmdObj = new System.Data.SqlClient.SqlCommand(SqlCmd, Con); Con.Open(); System.Data.SqlClient.SqlDataReader SqlReader = SqlCmdObj.ExecuteReader(); if (SqlReader.Read()) { System.IO.MemoryStream thumbStream = new System.IO.MemoryStream(); System.Web.HttpContext.Current.Response.ContentType = "image/jpeg"; System.Drawing.Image _image = System.Drawing.Image.FromStream(new System.IO.MemoryStream((byte[])SqlReader[imgname])); _image.Save(System.Web.HttpContext.Current.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg); _image.Clone(); _image.Dispose(); thumbStream.Close(); thumbStream.Dispose(); } Con.Close(); SqlReader.Close(); } } ***************************************************** Create another aspx page( say datalist.aspx ) & create a datalist Within the datalist, put this code : In the datalist.aspx.cs page write this code: imgupload2.ImageUrl = "imagedisplay.aspx?modelid=" + stmodelid + "&imgname=Floor1PlanPhoto"; where modelid is the imageid, imagename is the datafield name.These two (modelid & imagename) are passed through querystring in image.aspx page. ARPITA -- modified at 14:38 Friday 19th May, 2006