Anda di halaman 1dari 8

 TEMPLATE:A template is a set of HTML elements

and controls that make up the layout for a particular


portion of a control. For example, in the DataList
Web server control you can use a combination of
HTML elements and controls to create the layout for
each row of the list.
 Similarly, the DataGrid Web server control has a
default look for rows in the grid. However, you can
customize the grid's look by defining different
templates for individual rows, alternating rows,
selected rows, and so on.
 Note   Templates differ from styles. A template
defines the content of a section of a control — for
example, the contents of a row in the DataList
control. Styles, on the other hand, specify the
appearance of elements such as color, font, and so
on. Styles can apply to the control as a whole (for
Which Controls Support
Templates?
 Notall Web server controls support
templates. For the most part, templates are
supported by complex controls. In Visual
Studio, this includes the DataGrid,
DataList, and Repeater Web server
controls.
Repeater Control
 There is no default structure for the repeater
control the structure has to be provided by the
developer using collection of templates
provided by repeater control.
 Header Template
Item Template Presents
Alternating Item Template data
Separator Template
Footer Template
DATA LIST CONTROL
 It is a collection of templates where each and every template
has to be customized by the user as per the requirement.
{OR} This is not providing any structure by default.So it is
similar to Repeater Control.

Data List
Header Template
Item Template
Alternating Item Template
Separator Template Item
Template
Selected Item Template
Edit Item Template
Footer Template
 Each Template is provided with Style
Header Template  Header Style
Item Template  Item Style
These 2 provide built in formatting features means font
size,backgrounds colors.
 It comes with 2 properties as Repeat Direction and Repeat
Columns.
Steps to customize the
datagrid control
 After assigning the dataset and the datamember to
the datalist control.
 Right click on the dataset control and select the edit
template  item templates.
 Place the controls as per the requirement on the item
Template.
– For e.g.: Place 2 labels and one checkbox at the
item template.
 Set the following properties for the controls placed on
the itemTemplate.
– Id  specify the identifier for the control
– Databindings
 Text  container.dataitem.columnName
Steps to customize the
datagrid control
DataBindings

Bindable Property Simple Bindings

Text Container
DataItem

Empno
After Setting the id and Databindings property for all the controls
then right click on the datalist control and click on End Template
Editing.
[Optional]: for better look and feel right click and select autoformat
 Note in order to search for a control
present in datalist control
 Syntax 
datalistitem.FindControl(“ControlName”)

Anda mungkin juga menyukai