+TRepeater displays its content defined in templates repeatedly based on the given data specified by the DataSource or DataSourceID property. The repeated contents can be retrieved from the Items property. Each item is created by instantiating a template and each is a child control of the repeater. TRepeater provides the OnItemCommand event that serves as a central place to process all OnCommand events raised by child controls of the repeater items. And an OnItemCreated event is raised each time when a new item is created based on a template. +
++Like normal control templates, the repeater templates can contain static text, controls and special tags, which after instantiation, become child contents of the corresponding item. TRepeater defiens five templates for different purposes, +
++To populate data into the repeater items, set DataSource to a valid data object, such as array, TList, TMap, or a database table, and then call dataBind() for the repeater. That is, +
++Normally, you only need to do this when the page containing the repeater is initially requested. In postbacks, TRepeater is smart enough to remember the previous state, i.e., contents populated with datasource information.The following sample displays tabular data using TRepeater. +
++TRepeater can be used in more complex situations. As an example, we show how to use nested repeaters, i.e., repeater in repeater. This is commonly seen in master-detail data presentation. To use a repeater within another repeater, for an item for the outer repeater is created, we need to set the detail data source for the inner repeater. This can be achieved by responding to the OnItemDataBound event of the outer repeater which is raised right after an outer repeater item completes databinding (therefore, the data is available). +
++Besides displaying data, TRepeater can also be used to collect data from users. Validation controls can be placed in TRepeater templates to verify that user inputs are valid. +
++The PRADO component composer demo is a good example of such usage. It uses a repeater to collect the component property and event definitions. Users can also delete or adjust the order of the properties and events, which is implemented by responding to the OnItemCommand event of repeater. +
++See in the following yet another example showing how to use repeater to collect user inputs. +
+ID | +Name | +Quantity | +Price | +Imported | +
---|---|---|---|---|
<%#$this->Parent->DataItem['id']%> | +<%#$this->Parent->DataItem['name']%> | +<%#$this->Parent->DataItem['quantity']%> | +<%#$this->Parent->DataItem['price']%> | +<%#$this->Parent->DataItem['imported']?'Yes':'No'%> | +
<%#$this->Parent->DataItem['id']%> | +<%#$this->Parent->DataItem['name']%> | +<%#$this->Parent->DataItem['quantity']%> | +<%#$this->Parent->DataItem['price']%> | +<%#$this->Parent->DataItem['imported']?'Yes':'No'%> | +
Computer Parts Inventory | +
Regional Personnel | +|||||||
---|---|---|---|---|---|---|---|
<%#$this->Parent->DataItem %> | +
+
|
+