TemplateField::HeaderTemplate Property
Gets or sets the template for displaying the header section of a TemplateField object.
Assembly: System.Web (in System.Web.dll)
[BrowsableAttribute(false)] [TemplateContainerAttribute(typeof(IDataItemContainer))] [PersistenceModeAttribute(PersistenceMode::InnerProperty)] public: virtual property ITemplate^ HeaderTemplate { 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 header section of a TemplateField in a data-bound control. The default is nullptr, which indicates that this property is not set.
Use the HeaderTemplate property to specify the custom content displayed for the header section of a TemplateField object. Define the content by creating a template that specifies how the header section is rendered.
To specify a template, first place opening and closing <HeaderTemplate> tags between the opening and closing tags of the <TemplateField> element. Next, add the custom content between the opening and closing <HeaderTemplate> 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 HeaderTemplate property to create a custom template for the header section of a TemplateField field column in a GridView control. The template displays a check box that allows the user to show or hide the rows of the GridView control.
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.