Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
C#
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 by
C#
empPicture.ImageUrl = string.Format("EmpPicture.ashx?id={0}", emp.Id);
Posted
Comments
ZurdoDev 2-Jul-15 7:11am    
What is your question?
Sajid227 3-Jul-15 0:42am    
my question is when i retrieve image using empPicture.ImageUrl,and then try to save it in db,it can not save in the db

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900