TemplateField::AlternatingItemTemplate Property
Gets or sets the template for displaying the alternating items in a TemplateField object.
Assembly: System.Web (in System.Web.dll)
[TemplateContainerAttribute(typeof(IDataItemContainer), BindingDirection::TwoWay)] [PersistenceModeAttribute(PersistenceMode::InnerProperty)] [BrowsableAttribute(false)] public: virtual property ITemplate^ AlternatingItemTemplate { ITemplate^ get (); void set (ITemplate^ value); }
Property Value
Type: System.Web.UI::ITemplateA System.Web.UI::ITemplate-implemented object that contains the template for displaying the alternating items in a TemplateField. The default is nullptr, which indicates that this property is not set.
Use the AlternatingItemTemplate property to specify the custom content displayed for the alternating items in a TemplateField object. Define the content by creating a template that specifies how the alternating items are rendered.
Note |
|---|
The AlternatingItemTemplate property is commonly used in combination with the 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 <AlternatingItemTemplate> tags between the opening and closing tags of the <TemplateField> element. Next, add the custom content between the opening and closing <AlternatingItemTemplate> 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 TableCell object in the data-bound control contains the control. Next, use the Controls collection of the TableCell object to access the control. You can also use the FindControl method of the TableCell object to find the control, if the control has an ID property specified.
The following code example demonstrates how to use the AlternatingItemTemplate property to create a custom template for the alternating items in a TemplateField field column of a GridView control. The template is a variation of the template specified by the ItemTemplate property, where an image is displayed on the opposite side of the cell.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, 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.
Note