Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Mar 07, 2012 07:34 PM by Nokee
Mar 07, 2012 07:34 PM|LINK
(Please let me know if this doesn't belong in the right forum, I'm still a little new to the site)
I'm currently working on building an application that queries the database and returns 1 or more rows of data which each row contains a column designating an encoded string. This is what I do after running this query:
foreach (DataRow dtrData in datatableImage.Rows)
string strHEX = dtrData["encodedImageHEX"].ToString();
private void Base64ToImage(string strHEX)
byte imageBytes = Convert.FromBase64String(strHEX);
MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length);
ms.Write(imageBytes, 0, imageBytes.Length);
Image image = Image.FromStream(ms, true);
Response.ContentType = "image/jpeg";
The problem is that when the query returns multiple rows, only the first image is decoded and displayed on the page. It seems to completely ignore my foreach loop. Is there a way to output multiple decoded images to the page? My colleague mentioned about
using sessions to store the decoded data and just spitting out html <img> tags to the page (I want to be able to just display them immediately on the page WITHOUT having to save the image first).
If anyone can provide me with some guidance on how I can achieve this I would greatly appreciate it! Thanks!