A newer version of this page is available. Switch to the current version.

GridViewTemplates.EditForm Property

Gets or sets a template for displaying the edit form.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v18.2.dll


public virtual ITemplate EditForm { get; set; }

Property Value

Type Default Description


An object that implements the ITemplate interface.


The image below shows the Edit Form’s default layout:


You can provide any possible layout for the Edit Form using the EditForm template. For an example, see the ASPxGridView’s Edit Form Template demo.

If you use edit form templates, you must process the update manually in the ASPxGridView.RowUpdating event handler.


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


This example demonstrates how to create the Edit Form‘s template at runtime.

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using DevExpress.Web.ASPxEditors;
using DevExpress.Web.ASPxGridView;

public partial class _Default : System.Web.UI.Page {
    protected void Page_Load(object sender, EventArgs e) {
        ASPxGridView1.Templates.EditForm = new EditFormTemplate();
    protected void ASPxGridView1_RowUpdating(object sender,
    DevExpress.Web.Data.ASPxDataUpdatingEventArgs e) {
    e.NewValues["ProductName"] = (ASPxGridView1.FindEditFormTemplateControl("tbProductName") 
                as ASPxTextBox).Value;
    e.NewValues["UnitPrice"] = (ASPxGridView1.FindEditFormTemplateControl("spinUnitPrice") 
                 as ASPxSpinEdit).Value;

public class EditFormTemplate : ITemplate {
    public void InstantiateIn(Control container) {
        Table table = CreateHtmlTable();

        ASPxTextBox tb = new ASPxTextBox();
        tb.ID = "tbProductName";
        tb.CssFilePath = @"~/App_Themes/Soft Orange/{0}/styles.css";
        tb.CssPostfix = "Soft_Orange";
        tb.Value = DataBinder.Eval((container as 
              GridViewEditFormTemplateContainer).DataItem, "ProductName");

        ASPxSpinEdit spin = new ASPxSpinEdit();
        spin.ID = "spinUnitPrice";
        spin.CssFilePath = @"~/App_Themes/Soft Orange/{0}/styles.css";
        spin.CssPostfix = "Soft_Orange";
        spin.Value = DataBinder.Eval((container as 
             GridViewEditFormTemplateContainer).DataItem, "UnitPrice");

        ASPxGridViewTemplateReplacement tr = new ASPxGridViewTemplateReplacement();
        tr.ReplacementType = GridViewTemplateReplacementType.EditFormUpdateButton;
        Literal separator = new Literal();
        separator.Text = " | ";
        tr = new ASPxGridViewTemplateReplacement();
        tr.ReplacementType = GridViewTemplateReplacementType.EditFormCancelButton;

    Table CreateHtmlTable() {
        Table table = new Table();
        table.Rows.Add(new TableRow());
        table.Rows[0].Cells.AddRange(new TableCell[] { new TableCell(),
                                                       new TableCell(),
                                                       new TableCell()});
        table.Rows.Add(new TableRow());
        table.Rows[1].Cells.AddRange(new TableCell[] { new TableCell(),
                                                       new TableCell(),
                                                       new TableCell()});
        return table;