Display Image in Datalist from Database
Posted on 2014-01-13
I have several hundred employee records in a database which contain routine data like first name, last name, title, and employee photo. The photos are stored in the database table using type (image) along with other data such as name, title, etc. The photos need to be displayed on a search results page, along with the other relevant employee info.
What I need to do is bind the data from the database into a dataList, which I have done a million times before using just text, but have never had to serve up an image before. Looking at the "image" control I have placed on my page which should display the employee photo, I'm not quite sure how (or where) to bind it to the photo.
These photos will be called up "on-demand" and are not physically stored in a directory anywhere, so it doesn't seem appropriate to use the ImageUrl property to bind. Am I using the wrong control? Not sure how to start with this.
I have found a handful of articles on how to convert binary to image, but not sure if that's applicable since these are stored in the "image" format.
Any help would be much appreciated.