asp.net.ph

TemplateField Class

System.Web.UI.WebControls Namespace


.NET Framework version 2.0

Represents a field that displays custom content in a data-bound control.

TemplateField Class Members

Collapse   Constructors

Visibility Constructor Parameters
public TemplateField ( )

Collapse   Properties

Visibility Name Value Type Accessibility
public AlternatingItemTemplate ITemplate [ Get , Set ]
public ConvertEmptyStringToNull Boolean [ Get , Set ]
public EditItemTemplate ITemplate [ Get , Set ]
public FooterTemplate ITemplate [ Get , Set ]
public HeaderTemplate ITemplate [ Get , Set ]
public InsertItemTemplate ITemplate [ Get , Set ]
public ItemTemplate ITemplate [ Get , Set ]
public ValidateRequestMode ValidateRequestMode [ Get , Set ]

Collapse   Methods

Visibility Name Parameters Return Type
protected CopyProperties ( DataControlField newField ) Void
protected CreateField ( ) DataControlField
public ExtractValuesFromCell ( IOrderedDictionary dictionary , DataControlFieldCell cell , DataControlRowState rowState , Boolean includeReadOnly ) Void
public InitializeCell ( DataControlFieldCell cell , DataControlCellType cellType , DataControlRowState rowState , Int32 rowIndex ) Void
public ValidateSupportsCallback ( ) Void

Remarks

The TemplateField class is used by data-bound controls ( such as GridView and DetailsView ) to display custom content for each record displayed. When you need to display content in a data-bound control that is not provided by one of the predefined data control fields ( such as BoundField ), use the TemplateField class to create your custom user interface ( UI ). The TemplateField object is displayed differently depending on the data-bound control in which it is used. For example, the GridView control displays a TemplateField object as a column, and the DetailsView control displays it as a row.

You can define a custom template for the different parts of the TemplateField object using the templates listed in the following table.

Template Description
AlternatingItemTemplate Specifies the content to display for the alternating items in a TemplateField object.
EditItemTemplate Specifies the content to display for an item in edit mode in a TemplateField object.
FooterTemplate Specifies the content to display for the footer section of a TemplateField object.
HeaderTemplate Specifies the content to display for the header section of a TemplateField object.
InsertItemTemplate Specifies the content to display for an item in insert mode in a TemplateField object. This template is supported only by the DetailsView control.
ItemTemplate Specifies the content to display for the items in a TemplateField object.

You can hide a TemplateField object in a data-bound control by setting the Visible property to false.

As an alternative to defining a custom HeaderTemplate or FooterTemplate template, you can customize the header and footer sections of a TemplateField object by setting other properties of the TemplateField object. To display a caption in the header or footer sections, set the HeaderText or the FooterText property, respectively. Instead of displaying text in the header section, you can display an image by setting the HeaderImageUrl property. The header section can be hidden in the TemplateField object by setting the ShowHeader property to false.

NOTE: Some data-bound controls ( such as the GridView control ) can show or hide only the entire header section of the control. These data-bound controls do not support the ShowHeader property for an individual bound field. To show or hide the entire header section of a data-bound control, use the control's ShowHeader property ( if available ).

You also can customize the appearance of the TemplateField object ( font color, background color, and so on ) by setting the style properties for the different parts of the field. The following table lists the different style properties.

Style property Description
ControlStyle The style settings for the child Web server controls of the TemplateField object.
FooterStyle The style settings for the footer section of the TemplateField object.
HeaderStyle The style settings for the header section of the TemplateField object.
ItemStyle The style settings for the data items in the TemplateField object.

See Also

BoundField   ButtonField   CheckBoxField   CommandField   HyperLinkField   ImageField Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph