Binding to images stored in database...

C

Charlie

Hi:

When storing images (.gif, .jpg) in binary fields in SQL Server, how do I
bind them to asp.net image control without first writing them to a file and
attaching to URL property? For example, if I'm using a DataList that's
binds to a table in a database, and one column of table is an image field
containing a graphic, how do I bind it to an image control that is contained
in DataList template.

Thanks,
Charlie
 
G

Guest

Charlie, what you might want to consider is to change the url on the image
control to point to something like this "streamimage.aspx?recordid=1" where
recordid=1 could be a databinding evaluation to the unique id for the record.

Then, create a streamimage.aspx file that queries the database and retrieves
the binary data for the image, then use the Response.WriteFile(stream) method
to write the image to the output stream for the streamimage.aspx. This will
result in the behavior you desire...
 

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,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top