asp.net.ph

TemplateField.EditItemTemplate Property

System.Web.UI.WebControls Namespace   TemplateField Class


.NET Framework version 2.0

Specifies the template to use for editing a row of data in a TemplateField control.

Syntax

<asp:templatefield ... >

   <edititemtemplate>
      ... template definition here
   </edititemtemplate>

</asp:templatefield>

Property Value

An ITemplate interface that defines how the TemplateField control is rendered when in edit mode.

The property is read/write with no default value.

Remarks

Use the EditItemTemplate to define the layout of elements in the TemplateField control when editing a row of data.

The EditItemTemplate functions in the same way as the InsertItemTemplate, but is rendered only when the parent control of the TemplateField is in edit mode.

To specify a template for editing a row of data, declare an <EditItemTemplate> element between the opening and closing tags of the control. You can then list the contents of the template between the opening and closing <EditItemTemplate> ... </EditItemTemplate> tags.

In the EditItemTemplate, declare one or more input server controls ( TextBox, CheckBox, RadioButton, etc. ) and set their data-binding expressions to evaluate to a field in the parent control's data source.

To enable ItemTemplatethe built-in edit feature of the parent control, you must associate a field with an input control with a two-way binding expression, using the Bind method, as shown in the following example.

<asp:textbox maxlength=254 id = "msgSubject" runat = "server"
   text=<%# Bind ( "MessageSubject" ) %> />

This allows the parent control to automatically display the original field values in the associated input control when in edit mode, and extract these values when the form is posted.

To perform the built-in update and cancel operations, add the appropriate command button controls to the template and set their CommandName properties to "Update" and "Cancel", accordingly.

When the update command button is clicked and the page is posted for processing, the parent control of the TemplateField automatically extracts the inserted field values from each associated input control and updates the row of data in the underlying data source. For more information on two-way binding expressions, see DataBinding Expression Syntax.

To control the style of the edit row, use the EditRowStyle property of the parent control.

Example

The following example illustrates using the EditItemTemplate to enable users to edit a row of data.

 Show me 

See Also

TemplateField Members   InsertItemTemplate   ItemTemplate Skip Navigation Links




Home
Suggested Reading


Previous page Back to top Next page

© 2000-2010 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support asp.net.ph