How to display data-bound images inside a data view on a page.
See the chapter on using HTML-based views in the Programmer's Guide |
The approach illustrated here uses a label control, not an image control. You will set the label to be in raw HTML mode and tell it to generate HTML code that produces an image for each row based on the data.
Set up the image files and database as follows:
If you chose one of the HTML form page wizards when you created the page, you will already have associated a database with it.
If you chose the static page wizard, you will need to associate a database with the page by selecting the desired database in the Relational Data Palette.
In this step, you create a data view control and associate it with data.
tblEmployees.imageFile <> ""
In this step, you create a label control and sets its properties.
"<img src=\"../Objectstore/Images/" + tblEmployees.imageFile + ".gif\">"
The expression will be evaluated at runtime for each row shown in the data view.
<img src="../Objectstore/Images/filename.gif">
This step illustrates how to set the label control to in raw HTML mode. This is important because it means you do not have to escape any HTML tags in the expression.
// pageLoaded event of the page // Set the image label to raw HTML mode. Label1.setRawHTMLMode(true);
Try running the page. If you don't see the desired effect, view the source in the browser. It should have lines that look like this where the images are supposed to appear:
<img src="../Objectstore/Images/filename.gif">