Dynamic content in templates
Versions:
n/a,
FAQ number:
20,
Old FAQ number: 933
Q: Is it possible to have dynamic content in templates for a listing control for examle: Sometimes I would like to show a thumbnail picture in the beginning of a template and sometimes I don't. Is it possible to use for example a condition within a template?
A: You can acomplish this in several ways in .NET and here follows some guidlines and suggestions on how to do it.
1. Use the Web and Html controls in .NET
In the code behind file you create instances of Labels TableCells, then you add the instances to the Controls class for the desired control.
So how do you access the desired contol? Simply, trap the PreRender event which the listing fires just before it will generate the listing content. The following example adds a label which will be first in the control list of the listing.