aspnet-devexpress-dot-web-dot-gridviewdatacolumn-af1d912e.md
Specifies a template to display the column’s edit cell.
Namespace : DevExpress.Web
Assembly : DevExpress.Web.v25.2.dll
NuGet Package : DevExpress.Web
[DefaultValue(null)]
public virtual ITemplate EditItemTemplate { get; set; }
<DefaultValue(Nothing)>
Public Overridable Property EditItemTemplate As ITemplate
| Type | Default | Description |
|---|---|---|
| ITemplate | null |
An object that implements the ITemplate interface.
|
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) {
}
}
Public Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub glCategory_Load(ByVal sender As Object, ByVal e As EventArgs)
(TryCast(sender, ASPxGridLookup)).GridView.Width = New Unit(500, UnitType.Pixel)
End Sub
Protected Sub grid_RowInserting(ByVal sender As Object, ByVal e As DevExpress.Web.Data.ASPxDataInsertingEventArgs)
Throw New CallbackException("Operation is not allowed in demonstration mode")
End Sub
Protected Sub grid_RowUpdating(ByVal sender As Object, ByVal e As DevExpress.Web.Data.ASPxDataUpdatingEventArgs)
Throw New CallbackException("Operation is not allowed in demonstration mode")
End Sub
End Class
Public Class CallbackException
Inherits Exception
Public Sub New(ByVal message As String)
MyBase.New(message)
End Sub
End Class
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
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.
ASPxGridView grid = (ASPxGridView)sender;
((GridViewDataColumn)grid.Columns["DataValue"]).EditItemTemplate = new CustomEditItemTemplate();
}
Dim grid As ASPxGridView = DirectCast(sender, ASPxGridView)
CType(grid.Columns("DataValue"), GridViewDataColumn).EditItemTemplate = New CustomEditItemTemplate()
End Sub
See Also