Click here to Skip to main content
15,896,153 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
in my sql server db i have field name stuimage type image
i wanna display this image in asp:image id = "image1" in asp.net c#
using this code

C#
byte[] bytes = (byte[])x.Student_Picture;
string imgString = Convert.ToBase64String(bytes);
Image1.ImageUrl = String.Format("data:image/jpeg;base64,{0}",imgString );


when i run this code ... image1 is appeared empty

where is the error and how to solve it ?

best regards

What I have tried:

-----
byte[] imagem = (byte[])x.Student_Picture;
string base64String = Convert.ToBase64String(imagem, 0, imagem.Length);
images1.Src = "data:image/jpeg;base64," + base64String;
------------
Posted
Updated 22-Apr-16 2:44am
Comments
That should work. Have you debugged and saw if data is coming or not?
Mohamed-Hmy 20-Apr-16 2:40am    
no data appear
Debug and see what is the value of x.Student_Picture?
Mohamed-Hmy 21-Apr-16 2:41am    
Have a value
Then it should work.

1 solution

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