Employee.ImgBody = (Employee.ImgBody == null) ? new byte[0] : Employee.ImgBody; //Image saving code Byte[] imgByte = null; if (txtEpPicture.HasFile && txtEpPicture.PostedFile != null) { //To create a PostedFile HttpPostedFile File = txtEpPicture.PostedFile; //Create byte Array with file len imgByte = new Byte[File.ContentLength]; //force the control to load data in array File.InputStream.Read(imgByte, 0, File.ContentLength); Employee.ImgBody = imgByte; }
empPicture.ImageUrl = string.Format("EmpPicture.ashx?id={0}", emp.Id);