Tuesday 28 April 2015

Show Binary Image in ASP.NET without using handler | Bind Binary Image in ASP.NET

Here we are going to bind the binary image from database.
Our binary image in in the varbnary(max) formatted in the database.

We Need to Add HTML Image control in design view:
<img runat="server" id="ProfileImage" />

And in code behind we have to add this:
First bind the Dataset and write below this code
byte[] imageBytes=Convert.ToBase64String((byte[])'DataSet Image Field');//replace DataSet Image field with varbinary Field.
ProfileImage.Src = "data:image/png;base64,"imageBytes;


You are done all the steps. The image will be display.