System.Web.UI.WebControls Namespace TemplateColumn Class
Specifies the template to use for the item to edit in a TemplateColumn.
<asp:templatecolumn ... >
<edititemtemplate>
... template definition here
</edititemtemplate>
</asp:templatecolumn>
An ITemplate interface that defines how the item selected for editing in the TemplateColumn control is rendered.
The property is read/write with no default value.
Use the EditItemTemplate to define the appearance of the item selected for editing in a TemplateColumn.
The EditItemTemplate functions in the same way as the ItemTemplate, but rendered only for the row selected for editing in the TemplateColumn control. You can set the appearance for the item in this template using the EditItemStyle property.
To specify a template for the item to edit in a TemplateColumn, declare an <EditItemTemplate> element between the opening and closing tags of the column. You can then list the contents of the template between the opening and closing <EditItemTemplate> ... </EditItemTemplate>
tags.
The item in the EditItemTemplate is data-bound. To display data in the EditItemTemplate, declare one or more Web server controls and set their data-binding expressions to evaluate to a field in the parent DataGrid control's DataSource.
Contact: <asp:textbox id = "contact" runat = "server"
text='<%# ( ( DataRowView ) Container.DataItem ) [ "ContactName" ] %>' />
For more information, see DataBinding Expression Syntax.
The following example illustrates using the EditItemTemplate to display the item to edit in a TemplateColumn in a different layout and format.
<asp:templatecolumn headertext = "Type">
<itemtemplate>
<%# ( ( DataRowView ) Container.DataItem ) [ "Type" ] %>
</itemtemplate>
<edititemtemplate>
<asp:dropdownlist runat = "server" id = "myList"
datasource=<%# fetchListSource ( ) %>
datatextfield = "Type"
selectedindex='<%# getSelected (
( ( DataRowView ) Container.DataItem ) [ "Type" ].ToString ( ) ) %>' />
</edititemtemplate>
</asp:templatecolumn>
Show me
TemplateColumn Members EditItemIndex EditItemStyle Allowing Users to Edit Items in a DataGrid Control