images from database

C

cashdeskmac

Hi,

I have a set of images in a database and I am using a DataReader to retrive
them:

SqlDataReader dr = command.ExecuteReader();
if (dr.Read())
{

Byte[] b = (Byte[])dr["img_data"];
MemoryStream ms = new MemoryStream(b);
Image img = Image.FromStream(ms);
//create the html for the span
imageholder.InnerHtml = "";
}

Now that I have the Image, how can I assign it to the InnerHtml of the span
called imageholder (which has the attribute runat="server")?
 
E

Eliyahu Goldin

There is no inner html for image. Instead, there is an image source
attribute. You should put your code into a separate GetImage.aspx page that
will have no markup and call it like this:

<img ... src="GetImage.aspx?id=myImageId" />
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top