System.Web.UI.WebControls.TemplateField.ItemTemplate Property

Gets or sets the template for displaying an item in a data-bound control.

Syntax

[System.ComponentModel.Browsable(false)]
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
[System.Web.UI.TemplateContainer(typeof(System.Web.UI.IDataItemContainer), System.ComponentModel.BindingDirection.TwoWay)]
[System.ComponentModel.DefaultValue(null)]
public virtual System.Web.UI.ITemplate ItemTemplate { set; get; }

Value

Documentation for this section has not yet been entered.

Remarks

Use the TemplateField.ItemTemplate property to specify the custom content displayed for the items in a System.Web.UI.WebControls.TemplateField object. Define the content by creating a template that specifies how the items are rendered.

Note:

You can optionally define the TemplateField.AlternatingItemTemplate property in combination with the TemplateField.ItemTemplate property to create a different appearance for every other item in the data-bound control.

To specify a template, first place opening and closing <ItemTemplate> tags between the opening and closing tags of the <TemplateField> element. Next, add the custom content between the opening and closing <ItemTemplate> tags. The content can be as simple as plain text or more complex (embedding other controls in the template, for example).

To programmatically access a control defined in a template, first determine which System.Web.UI.WebControls.TableCell object in the data-bound control contains the control. Next, use the System.Web.UI.Control.Controls collection of the System.Web.UI.WebControls.TableCell object to access the control. You can also use the System.Web.UI.Control.FindControl(string) method of the System.Web.UI.WebControls.TableCell object to find the control, if the control has an System.Web.UI.Control.ID property specified.

Requirements

Namespace: System.Web.UI.WebControls
Assembly: System.Web (in System.Web.dll)
Assembly Versions: 2.0.0.0
Since: .NET 2.0