System.Web.UI.WebControls.FormView.ItemTemplate Property

Gets or sets the custom content for the data row in a System.Web.UI.WebControls.FormView control when the control is in read-only mode.

Syntax

[System.ComponentModel.Browsable(false)]
[System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)]
[System.Web.UI.TemplateContainer(typeof(System.Web.UI.WebControls.FormView), 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

The System.Web.UI.WebControls.FormView control renders a different template for the data row based on the current mode of the control (specified by the FormView.CurrentMode property). The following table shows which template is used for each mode.

Edit

FormView.EditItemTemplate

Insert

FormView.InsertItemTemplate

Read-only

FormView.ItemTemplate

Use the FormView.ItemTemplate property to define your own user interface (UI) for the data row when the System.Web.UI.WebControls.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 System.Web.UI.WebControls.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.

Delete

"Delete"

Edit

"Edit"

New

"New"

You can control the appearance of the item template by using the FormView.RowStyle property.

Requirements

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