asp.net.ph

FormView.InsertItemTemplate Property

System.Web.UI.WebControls Namespace   FormView Class


.NET Framework version 2.0

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

Syntax

<asp:formview ... >

   <insertitemtemplate>
      ... template definition here
   </insertitemtemplate>

</asp:formview>

Property Value

An ITemplate interface that defines how the FormView control is rendered when in insert mode.

The property is read/write with no default value.

Remarks

Use the InsertItemTemplate to define the layout of elements in the FormView control when adding a row of data.

The InsertItemTemplate functions in the same way as the EditItemTemplate, but is rendered only when the FormView control is in insert mode.

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

In the InsertItemTemplate, 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 insert 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 blank field values in the associated input control in insert mode, and extract these values when the form is posted.

To perform the built-in insert operation, add a command button control to the template and set its CommandName property to "Insert", accordingly.

When the insert 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 inserts 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 insert row, use the InsertRowStyle property.

Example

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

 Show me 

See Also

EditItemTemplate   InsertRowStyle   ItemTemplate   Allowing Users to Add Items 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