This documentation is archived and is not being maintained.

ListView::SelectedItemTemplate Property

Gets or sets the custom content for the selected item in a ListView control.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web.Extensions (in System.Web.Extensions.dll)

[PersistenceModeAttribute(PersistenceMode::InnerProperty)]
[BrowsableAttribute(false)]
[TemplateContainerAttribute(typeof(ListViewDataItem), BindingDirection::TwoWay)]
public:
virtual property ITemplate^ SelectedItemTemplate {
	ITemplate^ get ();
	void set (ITemplate^ value);
}
<asp:ListView>
	<SelectedItemTemplate>ITemplate</SelectedItemTemplate>
</asp:ListView>

Property Value

Type: System.Web.UI::ITemplate
An object that contains the custom content for the selected item in a ListView control. The default is nullptr, which indicates that this property is not set.

Use the SelectedItemTemplate property to define a custom user interface (UI) for the selected item in a ListView control. The SelectedItemTemplate is usually used to differentiate the selected item from the other displayed items. SelectedItemTemplate is rendered instead of the ItemTemplate template for the selected item.

To specify the custom template declaratively, add a SelectedItemTemplate element inside the ListView control. You can then add the contents of the template to the SelectedItemTemplate element. To display the field values of the data source that is bound to the control, use a data-binding expression. For more information, see Data-Binding Expressions Overview.

You can also add buttons to the SelectedItemTemplate. To create buttons that perform the built-in delete or edit operations, add a button control to the template and set its CommandName property to one of the values listed in the following table.

Button type

CommandName value

Delete

"Delete"

Edit

"Edit"

The following example shows how to use the SelectedItemTemplate property to define the contents of the selected item in the ListView control.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4, 3.5

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: