GridViewDataColumn.DataItemTemplate Property

Gets or sets a template for displaying data cells within the current column.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v21.2.dll


public virtual ITemplate DataItemTemplate { get; set; }

Property Value

Type Default Description


An object that implements the ITemplate interface.


To provide a common template for displaying data cells within the ASPxGridView, use the GridViewTemplates.DataItem property.


Once a template defined via the DataItemTemplate property is created within a control, it is instantiated within a container object of the GridViewDataItemTemplateContainer type. This container object exposes a set of specific properties to which the template’s child controls can be bound.

If to create a new row in Batch Edit Mode when a column implements a DataItemTemplate, only HTML markup of the row is copied. So, it is recommended to use the DataItemTemplate in Batch Edit mode only for appearance customization.

Online Example


Custom logic implemented in this example allows the end-user to select a limited number of named columns via comboboxes. The maximum number of columns the user can select is defined by a numeric column value, which he can also change. The only callback is used to post the entire grid page data. To work in multi-row-edit mode, scripts and ClientInstanceName property values are generated programmatically.


View Example

public void InstantiateIn(Control container)
    GridViewDataItemTemplateContainer gcontainer = (GridViewDataItemTemplateContainer)container;
    ASPxComboBox cbx = new ASPxComboBox();
    cbx.ID = "cbx_" + gcontainer.Column.FieldName;
    cbx.ValueType = typeof(bool);
    cbx.Items.Add("Yes", true);
    cbx.Items.Add("Blank", false);
    string code = DataBinder.Eval(gcontainer.DataItem, "Code") as string;
    bool value = string.IsNullOrEmpty(code) ? false : code.Contains(gcontainer.Column.FieldName);
    cbx.Value = value;
    cbx.Width = Unit.Pixel(80);
    int num = Convert.ToInt32(DataBinder.Eval(gcontainer.DataItem, "Num"));
    cbx.ClientEnabled = value || code.Length < num;
    cbx.ClientSideEvents.SelectedIndexChanged = "function(s,e){RefreshRow("+gcontainer.VisibleIndex+");}";
    cbx.ClientInstanceName = "cbx_" + gcontainer.Column.FieldName + gcontainer.VisibleIndex.ToString();
See Also