FormView.ItemTemplate Property
Assembly: System.Web (in system.web.dll)
[TemplateContainerAttribute(typeof(FormView), BindingDirection::TwoWay)] public: virtual property ITemplate^ ItemTemplate { ITemplate^ get (); void set (ITemplate^ value); }
/** @property */ public ITemplate get_ItemTemplate () /** @property */ public void set_ItemTemplate (ITemplate value)
public function get ItemTemplate () : ITemplate public function set ItemTemplate (value : ITemplate)
Not applicable.
Property Value
A System.Web.UI.ITemplate that contains the custom content for the data row when the FormView control is in read-only mode. The default value is null, which indicates that this property is not set.The FormView control renders a different template for the data row based on the current mode of the control (specified by the CurrentMode property). The following table shows which template is used for each mode.
| Mode | Template rendered |
|---|---|
| Edit | |
| Insert | |
| Read-only | ItemTemplate |
Use the ItemTemplate property to define your own user interface (UI) for the data row when the FormView control is in read-only mode. The item template usually contains controls to display the field values of a record, as well as command buttons to edit, insert, and delete a record.
To specify the custom template, first place <ItemTemplate> tags between the opening and closing tags of the FormView control. You can then list the contents of the template between the opening and closing <ItemTemplate> tags. To display the field values of the data source bound to the control, use a data-binding expression. For more information on data-binding expressions, see Data Binding Expression Syntax. To create command buttons that perform the built-in delete, edit, and new record operations, add a command button control to the template with its CommandName property set to one of the values listed in the following table.
| Command button type | CommandName value |
|---|---|
| Delete | "Delete" |
| Edit | "Edit" |
| New | "New" |
You can control the appearance of the item template by using the RowStyle property.
Reference
FormView ClassFormView Members
System.Web.UI.WebControls Namespace
System.Web.UI.ITemplate
RowStyle
FormView.EditItemTemplate Property
FormView.EmptyDataTemplate Property
FormView.FooterTemplate Property
FormView.HeaderTemplate Property
FormView.InsertItemTemplate Property
PagerTemplate