in .aspx.cs page , dynamically set the IMageUrl for image
img.ImageUrl= "MyHandler.ashx?myImageID=blueimage";
in .ashx page
public void ProcessRequest(HttpContext context)
{
string imagename = context.Request.QueryString.Get("myImageID").ToString();
// using the image name, use SQLDATAADAPTER and get the image
// by filling DATASET and type cast to byte[] (byte array)
byte[] imageBinaryData = new byte[100];// this is just for testing purpose .. u need to get data from sql.. showing u the syntax
context.Response.BinaryWrite(imageBinaryData);
}
Thanks
Siva Phani
Mark the post as Answer if it helps.
maverickprot...
Member
64 Points
86 Posts
displaying binary data(images) asp.net page c#
Aug 06, 2011 10:53 PM|LINK
hello,
how do we display images stored in database in binary format on a asp.net page
and in a grid view
also is it possible to display resized images ideally constrained proportions thumbnails
at present images stored in binary format are large size
regards,
robwscott
Star
8079 Points
1491 Posts
Re: displaying binary data(images) asp.net page c#
Aug 06, 2011 11:02 PM|LINK
this will help. used this on my last project.
http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/bbee4a78-fd4a-402c-9c56-aba51946458c/
Mark Answered if it helps - Good luck!
Cheers!
Design And Align
- Rob
Nasser Malik
Star
11228 Points
1720 Posts
Re: displaying binary data(images) asp.net page c#
Aug 06, 2011 11:11 PM|LINK
1. show image in gridview / any image control from db..
you can make new page or use ashx handler to get image for you from db and set this page path in imageurl and pass the imagename name as parameter
see the following example
Display Images In GridView From DataBase C# VB.NET
and for resizing see the example
Resizing images retrieved from SQL server
Skype: maleknasser1
mudassarkhan
All-Star
78956 Points
13402 Posts
MVP
Re: displaying binary data(images) asp.net page c#
Aug 09, 2011 11:21 PM|LINK
http://www.aspsnippets.com/Articles/Display-images-from-SQL-Server-Database-in-ASP.Net-GridView-control.aspx
http://www.aspsnippets.com/Articles/Display-Images-from-SQL-Server-Database-using-ASP.Net.aspx
Contact me
msdnphani
Contributor
2387 Points
488 Posts
Re: displaying binary data(images) asp.net page c#
Aug 16, 2011 02:15 PM|LINK
in .aspx.cs page , dynamically set the IMageUrl for image img.ImageUrl= "MyHandler.ashx?myImageID=blueimage"; in .ashx page public void ProcessRequest(HttpContext context) { string imagename = context.Request.QueryString.Get("myImageID").ToString(); // using the image name, use SQLDATAADAPTER and get the image // by filling DATASET and type cast to byte[] (byte array) byte[] imageBinaryData = new byte[100];// this is just for testing purpose .. u need to get data from sql.. showing u the syntax context.Response.BinaryWrite(imageBinaryData); }Siva Phani
Mark the post as Answer if it helps.