Click here to Skip to main content
15,887,175 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
Hye, I have a database which contains columns of USER_IMAGE , USER_NAME, USER_AGE.
I want to display the image of the user on the aspx page (front end). How I can show the picture on the aspx page. Please help me. By the way i am displaying the USER_Name and USER_AGE in the label. I mean i am getting the values of USER_NAME and USER_AGE in string. Then i am passing that string to label, which i am showing on front page. How I can do same with Image??

What I have tried:

Right now i have no code. By the way i have stored images in the database.
Posted
Updated 21-Apr-17 11:12am
Comments
[no name] 21-Apr-17 16:09pm    
And when you googled how to do this and/or looked over to the right side of this page and looked at the "Related Questions", you found nothing at all telling you how to do this? I find that very hard to believe.

1 solution

ASP.NET
<asp:Image ID="ImgProfilePic" runat="server"  />


C#
// Get your image from database, I hope it is stored in binary format, so it would return a byte array


byte[] imagem = (byte[])(dr["IMG"]);
string PROFILE_PIC = Convert.ToBase64String(imagem);

ImgProfilePic.ImageUrl = String.Format("data:image/jpg;base64,{0}", PROFILE_PIC); 
 
Share this answer
 

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