GridViewDataColumn.EditItemTemplate Property
Specifies a template to display the column’s edit cell.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v21.2.dll
NuGet Package: DevExpress.Web
Declaration
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.
<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) {
}
}
See Also