i have a form in which i can save data about employee
including image.image is saving/retrieve properly ,problem is
that when i retrieve image is time then save or update the record
without selecting image ,image is not going to save. i am using following code to save image
Hide Copy Code
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; }
and retriving image byHide Copy Code
empPicture.ImageUrl = string.Format("EmpPicture.ashx?id={0}", emp.Id);
problem is when image is retrieve 1st time then save again it does not save in db,