I have a SQL Server 2008 database that has image field which contains a picture.
I have a gridview in my ASP.NET web program, and I need to show the picture in:
my gridview
my image control that I have in the form
Can I get any sample code ?
Thanks in advance.
I believe that the Image will come over as binary. You will need to convert the binary to image.
These references will help you with the conversion
Silverlight 4.0: How to convert byte[] to image?
http://www.eggheadcafe.com/community/aspnet/2/10038022/convert-binary-data-to-an-image.aspx
use Generic handler to fetch image from database and to show that use ifram that will be better option to show files on web.
And this is a Generic handler code to show image files and also for pdf files. if you just want to show image files just remove if else conditions and use image/jpeg for extension.
You could use the data uri scheme with base64 (assuming it is stored in base64) string i.e.
See http://en.wikipedia.org/wiki/Data_URI_scheme
So for example if you were using a databound control you would i.e. for a repeater do this: