asp.net.ph

FormView.EditItemTemplate Property

System.Web.UI.WebControls Namespace   FormView Class


.NET Framework version 2.0

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

Syntax

<asp:formview ... >

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

</asp:formview>

Property Value

An ITemplate interface that defines how the FormView 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 FormView control when editing a row of data.

The EditItemTemplate functions in the same way as the InsertItemTemplate, but is rendered only when the FormView control 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 FormView control's data source.

To enable the built-in edit feature of the FormView 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 FormView control to automatically display the original field values in the associated input control 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 FormView control 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.

Example

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

 Show me 

See Also

EditRowStyle   InsertItemTemplate   ItemTemplate   Allowing Users to Edit Rows in a FormView Control 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