Skip to main content
Tab

GridViewColumn.HeaderCaptionTemplate Property

Specifies a template to display the column header caption.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v23.2.dll

NuGet Package: DevExpress.Web

Declaration

[DefaultValue(null)]
public virtual ITemplate HeaderCaptionTemplate { get; set; }

Property Value

Type Default Description
ITemplate null

An object that implements the ITemplate interface.

Remarks

When you specify the HeaderCaptionTemplate property, the control creates a template within a container object of the GridViewHeaderTemplateContainer type.

At the control level, use the HeaderCaption property to create a template for column header captions.

Example

In the example below, the header caption template contains ASPxCheckBox.

Handle the onmousedown and onmouseup events to disable the sort mode for a column.

View Example: How to specify HeaderCaptionTemplate and prevent the default mouse actions

<dx:ASPxGridView ID="grid" runat="server" AutoGenerateColumns="False">
    <Columns>
        <dx:GridViewDataTextColumn FieldName="ProductID" ReadOnly="True" VisibleIndex="0">
            <EditFormSettings Visible="False" />
        </dx:GridViewDataTextColumn>
        <dx:GridViewDataTextColumn FieldName="ProductName" VisibleIndex="1" />
        <dx:GridViewDataComboBoxColumn FieldName="CategoryID" VisibleIndex="2">
            <PropertiesComboBox ValueType="System.Int32" TextField="CategoryName"
                ValueField="CategoryID" />
            <HeaderCaptionTemplate>
                <div onmousedown="return CancelEvent(event)" onmouseup="return CancelEvent(event)">
                    <dx:ASPxComboBox ID="cmb" runat="server" DataSourceID="dsCmb" ValueType="System.String"
                        TextField="CategoryName" ValueField="CategoryID">
                        <ClientSideEvents SelectedIndexChanged="OnSelectedIndexChanged" />
                    </dx:ASPxComboBox>
                </div>
            </HeaderCaptionTemplate>
        </dx:GridViewDataComboBoxColumn>
        <dx:GridViewDataTextColumn FieldName="UnitPrice" VisibleIndex="3" />
    </Columns>
</dx:ASPxGridView>
function OnSelectedIndexChanged(s, e) {
    alert(s.GetText());
}
function CancelEvent(evt) {
    return ASPxClientUtils.PreventEventAndBubble(evt);
}
See Also