Skip to main content
Tab

GridViewDataColumn.EditItemTemplate Property

Specifies a template to display the column’s edit cell.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v24.1.dll

NuGet Package: DevExpress.Web

Declaration

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

Property Value

Type Default Description
ITemplate null

An object that implements the ITemplate interface.

Remarks

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

When you use an edit item template, the control does not update the data source automatically. Handle the RowUpdating event to manually update the data source.

In the example below, the edit item template contains ASPxGridLookup that allows you to choose a value from the Categories data source.

View Example: How to use two-way data-bound ASPxGridLookup in edit form of ASPxGridView to edit data

<dx:ASPxGridView ID="grid" runat="server" AutoGenerateColumns="False" KeyFieldName="ProductID"
    OnRowInserting="grid_RowInserting" OnRowUpdating="grid_RowUpdating">
    <Columns>
        <%--...--%>
        <dx:GridViewDataComboBoxColumn FieldName="CategoryID" VisibleIndex="1">
            <PropertiesComboBox TextField="CategoryName" ValueField="CategoryID"
                ValueType="System.Int32">
            </PropertiesComboBox>
            <EditItemTemplate>
                <dx:ASPxGridLookup ID="glCategory" runat="server" DataSourceID="dsCategories"
                    AutoGenerateColumns="False" KeyFieldName="CategoryID" OnLoad="glCategory_Load" 
                    TextFormatString="{1}" Value='<%# Bind("CategoryID") %>' Width="260px">
                    <GridViewProperties>
                        <SettingsBehavior AllowFocusedRow="True" AllowSelectByRowClick="True" 
                            AllowSelectSingleRowOnly="True" />
                        <SettingsBehavior AllowFocusedRow="True" AllowSelectByRowClick="True" 
                            AllowSelectSingleRowOnly="True" />
                    </GridViewProperties>
                    <Columns>
                        <%--...--%>
                    </Columns>
                </dx:ASPxGridLookup>
            </EditItemTemplate>
        </dx:GridViewDataComboBoxColumn>
        <%--...--%>
    </Columns>
</dx:ASPxGridView>
<asp:SqlDataSource ID="dsCategories" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
    SelectCommand="SELECT [CategoryID], [CategoryName], [Description] FROM [Categories]">
</asp:SqlDataSource>
public partial class _Default : System.Web.UI.Page {
    protected void glCategory_Load(object sender, EventArgs e) {
        (sender as ASPxGridLookup).GridView.Width = new Unit(500, UnitType.Pixel);
    }
    protected void grid_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e) {
        throw new CallbackException("Operation is not allowed in demonstration mode");
    }
    protected void grid_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e) {
        throw new CallbackException("Operation is not allowed in demonstration mode");
    }
}

public class CallbackException : Exception {
    public CallbackException(string message)
        : base(message) {
    }
}

Online Examples

View Example: How to use an edit item and data item templates in batch mode

View Example: How to use cascading combo boxes in inline edit mode

View Example: How to upload files and save them to a binary column in edit mode

Online Examples

View Example: Grid View for ASP.NET Web Forms - How to use the Rich Text Editor to edit formatted text in the Edit Form

View Example: How to use ASPxGridLookup in multiple selection mode as the ASPxGridView editor (WebForms)

View Example: How to use GridLookup with single selection mode in EditForm (MVC)

View Example: How to use GridLookup in EditForm in multiple selection mode (MVC)

View Example: Grid View for ASP.NET Web Forms - How to implement an edit item template in batch mode

View Example: Grid View for ASP.NET MVC - How to implement an edit item template in batch mode

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the EditItemTemplate property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also