Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
110
Anything wrong with directly putting img src code in cell?
posted

I'm able to display images in a column but simply having the column values be an html image tag. (e.g. <img src="12345.jpg">).  This seems too easy. I can easily display custom images without any extra grid code by having my database view return the image tag string.

Is there anything wrong with this method as opposed to setting the Style.Background field programmatically?

For those interested, here's an example of my TableAdapter view:

SELECT
StudyID,
ScenarioID,
'Screenshot'='<img src="images/' + StudyID+'.jpg' + '">'
 FROM dbo.Studies order by StudyID

In the grid, I didn't have to do anything special for the "Screenshot" column.  It shows the image as expected.  I can then set the cell padding to provide some space around the images.