Most web server controls have default layouts and appearances, but you can manipulate them by setting properties or using styles. Some web server controls also allow you to use templates to define its appearance.
Templates are a set of HTML elements and controls that make up the layout of the components specific part. For example, in the DataList Web Server Control, you can use HTML elements and control combinations to create layouts in the list. Similarly, DataGrid Web Server Controls have a default look at each line in the grid. However, you can define different templates from definition grid.
Note that the template is different from the style. Template defines "content" of a part of the control, for example
The content of the DataList control. On the other hand, the style specifies the "appearance" of the element, such as color, font, and the like. Style can be applied as a whole to the control (for example, set
DataGrid control fonts and template items.
The template contains HTML, or even embedded server controls. When the control is running in the web form page, the control frame presents the contents of the template, not the default HTML of the control.
Which controls support templates?
Not all web server controls support templates. In most cases, complex control support templates. This will include DataGrid, DataList, and Repeater Web Server Controls. (In fact, Repeater and DataList controls not only support templates, but also create templates to define their output.) You can also support templates from other sources.
A set of templates supported by each control is slightly different, and these templates specify the layout of different parts of the control, such as title, footnotes, items, and options. You can specify a template for any of the above or all objects, depending on which object you want to customize. In the DataGrid control, you can specify columns (rather than rows).
The following table summarizes the web server control of the template:
Control template REPEATER
HeadeRtemplate Footertemplate ItemTemplate AlternatingItemTemplate SeparatorTemplate DataList
HeadeRtemplate Footertemplate ItemTemplate AlternatingItemTemplate SeparatorTemplate SelectedItemTemplate EditItemplate DataGrid
Headertemplate Footertemplate ItemTemplate (Column) EditItemTemplate (Column) Pager
Create a template