System.Web 2.0.0.0 System.Web.UI.WebControls.CompositeDataBoundControl System.Web.UI.IDataItemContainer System.Web.UI.IPostBackEventHandler System.Web.UI.WebControls.IPostBackContainer System.ComponentModel.DefaultEvent("PageIndexChanging") System.Web.UI.ControlValueProperty("SelectedValue") System.ComponentModel.Designer("System.Web.UI.Design.WebControls.FormViewDesigner, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.ComponentModel.Design.IDesigner") System.Web.UI.SupportsEventValidation

In this topic:

Introduction

Templates

Binding to Data

Data Operations

Customizing the User Interface

Events

Accessibility

Applying CSS Styles

Declarative Syntax

## Introduction

The control is used to display a single record from a data source. It is similar to the control, except it displays user-defined templates instead of row fields. Creating your own templates gives you greater flexibility in controlling how the data is displayed. The control supports the following features:

Binding to data source controls, such as and .

Built-in inserting capabilities.

Built-in updating and deleting capabilities.

Built-in paging capabilities.

Programmatic access to the object model to dynamically set properties, handle events, and so on.

Customizable appearance through user-defined templates, themes, and styles.

## Templates

For the control to display content, you need to create templates for the different parts of the control. Most templates are optional; however, you must create a template for the mode in which the control is configured. For example, a control that supports inserting records must have an insert item template defined. The following table lists the different templates that you can create.

Template type

Description

Defines the content for the data row when the control is in edit mode. This template usually contains input controls and command buttons with which the user can edit an existing record.

Defines the content for the empty data row displayed when the control is bound to a data source that does not contain any records. This template usually contains content to alert the user that the data source does not contain any records.

Defines the content for the footer row. This template usually contains any additional content you would like to display in the footer row.

As an alternative, you can simply specify text to display in the footer row by setting the property.

Defines the content for the header row. This template usually contains any additional content you would like to display in the header row.

As an alternative, you can simply specify text to display in the header row by setting the property.

Defines the content for the data row when the control is in read-only mode. This template usually contains content to display the values of an existing record.

Defines the content for the data row when the control is in insert mode. This template usually contains input controls and command buttons with which the user can add a new record.

Defines the content for the pager row displayed when the paging feature is enabled (when the property is set to true). This template usually contains controls with which the user can navigate to another record.

The control has a built-in pager row user interface (UI). You need to create a pager template only if you want to create your own custom pager row.

To display the value of a field in an item template, use a data binding expression. For more information on data binding expressions, see Data Binding Expression Syntax.

Input controls in the edit item template and insert item template can be bound to the fields of a data source by using a two-way binding expression. This allows the control to automatically extract the values of the input control for an update or insert operation. Two-way binding expressions also allow input controls in an edit item template to automatically display the original field values. For more information on two-way binding expressions, see ASP.NET Data Binding.

## Binding to Data

The control can be bound to a data source control (such as , , or ) or to any data source collection that implements the interface, such as , , , or other collection types. Use one of the following methods to bind the control to the appropriate data source type:

To bind to a data source control, set the property of the control to the value of the data source control. The control automatically binds to the specified data source control and can take advantage of the data source control's capabilities to perform inserting, updating, deleting, and paging functionality. This is the preferred method to bind to data.

To bind to a data source that implements the interface, programmatically set the property of the control to the data source and then call the method. When using this method, the control does not provide built-in inserting, updating, deleting, and paging functionality. You need to provide this functionality by using the appropriate event.

For more information on data binding, see Accessing Data with ASP.NET.

This control can be used to display user input, which might include malicious client script. Check any information that is sent from a client for executable script, SQL statements, or other code before displaying it in your application. Whenever possible, it is strongly recommended that values are HTML-encoded before they are displayed in this control. ASP.NET provides an input request validation feature to block script and HTML in user input. Validation server controls are also provided to assess user input. For more information, see Introduction to the Validation Controls.

## Data Operations

The control provides many built-in capabilities that allow the user to update, delete, insert, and page through items in the control. When the control is bound to a data source control, the control can take advantage of the data source control's capabilities and provide automatic updating, deleting, inserting, and paging functionality.

The control can provide support for update, delete, insert, and paging operations with other types of data sources; however, you must provide an appropriate event handler with the implementation for these operations.

Because the control uses templates, it does not provide a way to automatically generate command buttons to perform updating, deleting, or inserting operations. You must manually include these command buttons in the appropriate template. The control recognizes certain buttons that have their CommandName properties set to specific values. The following table lists the command buttons that the control recognizes.

Button

CommandName value

Description

Cancel

"Cancel"

Used in updating or inserting operations to cancel the operation and to discard the values entered by the user. The control then returns to the mode specified by the property.

Delete

"Delete"

Used in deleting operations to delete the displayed record from the data source. Raises the and events.

Edit

"Edit"

Used in updating operations to put the control in edit mode. The content specified in the property is displayed for the data row.

Insert

"Insert"

Used in inserting operations to attempt to insert a new record in the data source using the values provided by the user. Raises the and events.

New

"New"

Used in inserting operations to put the control in insert mode. The content specified in the property is displayed for the data row.

Page

"Page"

Used in paging operations to represent a button in the pager row that performs paging. To specify the paging operation, set the CommandArgument property of the button to "Next", "Prev", "First", "Last", or the index of the page to which to navigate. Raises the and events.

This type of button is typically used only in the pager template.

Update

"Update"

Used in updating operations to attempt to update the displayed record in the data source with the values provided by the user. Raises the and events.

Unlike the Delete button (which deletes the displayed record immediately), when the Edit or New button is clicked, the control goes into edit or insert mode, respectively. In edit mode, the content contained in the property is displayed for the current data item. Typically, the edit item template is defined such that the Edit button is replaced with an Update and a Cancel button. Input controls that are appropriate for the field's data type (such as a or a control) are also usually displayed with a field's value for the user to modify. Clicking the Update button updates the record in the data source, while clicking the Cancel button abandons any changes.

Likewise, the content contained in the property is displayed for the data item when the control is in insert mode. The insert item template is typically defined such that the New button is replaced with an Insert and a Cancel button, and empty input controls are displayed for the user to enter the values for the new record. Clicking the Insert button inserts the record in the data source, while clicking the Cancel button abandons any changes.

The control provides a paging feature, which allows the user to navigate to other records in the data source. When enabled, a pager row is displayed in the control that contains the page navigation controls. To enable paging, set the property to true. You can customize the pager row by setting the properties of objects contained in the and the property. Instead of using the built-in pager row UI, you can create your own UI by using the property.

## Customizing the User Interface

You can customize the appearance of the control by setting the style properties for the different parts of the control. The following table lists the different style properties.

Style property

Description

The style settings for the data row when the control is in edit mode.

The style settings for the empty data row displayed in the control when the data source does not contain any records.

The style settings for the footer row of the control.

The style settings for the header row of the control.

The style settings for the data row when the control is in insert mode.

The style settings for the pager row displayed in the control when the paging feature is enabled.

The style settings for the data row when the control is in read-only mode.

## Events

The control provides several events that you can program against. This allows you to run a custom routine whenever an event occurs. The following table lists the events supported by the control.

Event

Description

Occurs when a button within a control is clicked. This event is often used to perform a task when a button is clicked in the control.

Occurs after all objects are created in the control. This event is often used to modify the values of a record before it is displayed.

Occurs when a Delete button (a button with its CommandName property set to "Delete") is clicked, but after the control deletes the record from the data source. This event is often used to check the results of the delete operation.

Occurs when a Delete button is clicked, but before the control deletes the record from the data source. This event is often used to cancel the delete operation.

Occurs when an Insert button (a button with its CommandName property set to "Insert") is clicked, but after the control inserts the record. This event is often used to check the results of the insert operation.

Occurs when an Insert button is clicked, but before the control inserts the record. This event is often used to cancel the insert operation.

Occurs when an Update button (a button with its CommandName property set to "Update") is clicked, but after the control updates the row. This event is often used to check the results of the update operation.

Occurs when an Update button is clicked, but before the control updates the record. This event is often used to cancel the update operation.

Occurs after the control changes modes (to edit, insert, or read-only mode). This event is often used to perform a task when the control changes modes.

Occurs before the control changes modes (to edit, insert, or read-only mode). This event is often used to cancel a mode change.

Occurs when one of the pager buttons is clicked, but after the control handles the paging operation. This event is commonly used when you need to perform a task after the user navigates to a different record in the control.

Occurs when one of the pager buttons is clicked, but before the control handles the paging operation. This event is often used to cancel the paging operation.

## Accessibility

For information about how to configure this control so that it generates markup that conforms to accessibility standards, see Accessibility in Visual Studio 2010 and ASP.NET 4 and ASP.NET Controls and Accessibility.

## Applying CSS Styles

The control lets you specify CSS style rules in markup. If you use templates to customize the appearance of the control, you can specify CSS styles in the markup in the templates. In that case, no extra outer table is required. You can prevent the table from being rendered by setting the property to false.

## Declarative Syntax

`<asp:FormView AccessKey="string" AllowPaging="True|False" BackColor="color name|#dddddd" BackImageUrl="uri" BorderColor="color name|#dddddd" BorderStyle="NotSet|None|Dotted|Dashed|Solid|Double|Groove|Ridge| Inset|Outset" BorderWidth="size" Caption="string" CaptionAlign="NotSet|Top|Bottom|Left|Right" CellPadding="integer" CellSpacing="integer" CssClass="string" DataKeyNames="string" DataMember="string" DataSource="string" DataSourceID="string" DefaultMode="ReadOnly|Edit|Insert" EmptyDataText="string" Enabled="True|False" EnableTheming="True|False" EnableViewState="True|False" Font-Bold="True|False" Font-Italic="True|False" Font-Names="string" Font-Overline="True|False" Font-Size="string|Smaller|Larger|XX-Small|X-Small|Small|Medium| Large|X-Large|XX-Large" Font-Strikeout="True|False" Font-Underline="True|False" FooterText="string" ForeColor="color name|#dddddd" GridLines="None|Horizontal|Vertical|Both" HeaderText="string" Height="size" HorizontalAlign="NotSet|Left|Center|Right|Justify" ID="string" OnDataBinding="DataBinding event handler" OnDataBound="DataBound event handler" OnDisposed="Disposed event handler" OnInit="Init event handler" OnItemCommand="ItemCommand event handler" OnItemCreated="ItemCreated event handler" OnItemDeleted="ItemDeleted event handler" OnItemDeleting="ItemDeleting event handler" OnItemInserted="ItemInserted event handler" OnItemInserting="ItemInserting event handler" OnItemUpdated="ItemUpdated event handler" OnItemUpdating="ItemUpdating event handler" OnLoad="Load event handler" OnModeChanged="ModeChanged event handler" OnModeChanging="ModeChanging event handler" OnPageIndexChanged="PageIndexChanged event handler" OnPageIndexChanging="PageIndexChanging event handler" OnPreRender="PreRender event handler" OnUnload="Unload event handler" PageIndex="integer" PagerSettings-FirstPageImageUrl="uri" PagerSettings-FirstPageText="string" PagerSettings-LastPageImageUrl="uri" PagerSettings-LastPageText="string" PagerSettings-Mode="NextPrevious|Numeric|NextPreviousFirstLast| NumericFirstLast" PagerSettings-NextPageImageUrl="uri" PagerSettings-NextPageText="string" PagerSettings-PageButtonCount="integer" PagerSettings-Position="Bottom|Top|TopAndBottom" PagerSettings-PreviousPageImageUrl="uri" PagerSettings-PreviousPageText="string" PagerSettings-Visible="True|False" RenderTable="True|False" runat="server" SkinID="string" Style="string" TabIndex="integer" ToolTip="string" Visible="True|False" Width="size" > <EditItemTemplate> <!-- child controls --> </EditItemTemplate> <EditRowStyle /> <EmptyDataRowStyle /> <EmptyDataTemplate> <!-- child controls --> </EmptyDataTemplate> <FooterStyle /> <FooterTemplate> <!-- child controls --> </FooterTemplate> <HeaderStyle /> <HeaderTemplate> <!-- child controls --> </HeaderTemplate> <InsertItemTemplate> <!-- child controls --> </InsertItemTemplate> <InsertRowStyle /> <ItemTemplate> <!-- child controls --> </ItemTemplate> <PagerSettings FirstPageImageUrl="uri" FirstPageText="string" LastPageImageUrl="uri" LastPageText="string" Mode="NextPrevious|Numeric|NextPreviousFirstLast| NumericFirstLast" NextPageImageUrl="uri" NextPageText="string" OnPropertyChanged="PropertyChanged event handler" PageButtonCount="integer" Position="Bottom|Top|TopAndBottom" PreviousPageImageUrl="uri" PreviousPageText="string" Visible="True|False" /> <PagerStyle /> <PagerTemplate> <!-- child controls --> </PagerTemplate> <RowStyle /> </asp:FormView>`

Displays the values of a single record from a data source using user-defined templates. The control allows you to edit, delete, and insert records.

- Constructor

  Use this constructor to initialize a new instance of the class. To dynamically add a control to a page, create a new object, set its properties, and then add it to the collection of a container control, such as .

  Initializes a new instance of the class.

  2.0.0.0
- Property
  System.ComponentModel.DefaultValue(false)
  System.Boolean To be added.

  The control has built-in paging capabilities, which allow a user to navigate to a different record in the data source. The paging feature can be used with any data source object that supports the interface or a data source that supports paging capability.

  To enable the paging feature, set the property to true. You can determine the total number of items in the underlying data source by using the property. To determine the index of the currently displayed item, use the property.

  When paging is enabled, an additional row called the pager row is automatically displayed in the control. The pager row contains the page navigation controls and can be displayed at the top, bottom, or both the top and bottom of the control. The pager row has four built-in pager display modes. The following table describes the four modes.

  Mode

  Description

  PagerButton.NextPrevious

  A set of pagination controls consisting of previous and next buttons.

  PagerButton.NextPreviousFirstLast

  A set of pagination controls consisting of previous, next, first, and last buttons.

  PagerButton.Numeric

  A set of pagination controls consisting of numbered link buttons to access pages directly. This is the default mode.

  PagerButton.NumericFirstLast

  A set of pagination controls consisting of numbered and first and last link buttons.

  The control automatically hides the pager row when the data source contains fewer than two records.

  You can control the settings of the pager row (such as the pager display mode, the number of page links to display at a time, and the pager control's text label) by using the property. To control the appearance of the pager row (including its background color and font color), use the property. The control also allows you to define a custom template for the pager row. For more information on creating a custom pager row template, see .

  The control provides several events that you can use to perform a custom action when paging occurs. The following table lists the available events.

  Event

  Description

  Occurs when one of the pager buttons is clicked, but after the control handles the paging operation. This event is commonly used when you need to perform a task after the user navigates to a different record in the control.

  Occurs when one of the pager buttons is clicked, but before the control handles the paging operation. This event is often used to cancel the paging operation.

  These events are not raised when you change the property programmatically.

  Gets or sets a value indicating whether the paging feature is enabled.

  2.0.0.0
- Property
  System.ComponentModel.Editor("System.Web.UI.Design.ImageUrlEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
  System.ComponentModel.DefaultValue("")
  System.Web.UI.UrlProperty
  System.String To be added.

  Use the property to specify the URL to an image to display in the background of a control.

  If the specified image is smaller than the control, the image is tiled to fill in the background. If the image is larger than the control, the image is cropped.

  Gets or sets the URL to an image to display in the background of a control.

  2.0.0.0
- Property
  System.ComponentModel.Browsable(false)
  System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)
  System.Web.UI.WebControls.FormViewRow To be added.

  When paging is enabled (when the property is set to true), an additional row called the pager row is automatically displayed in the control. The pager row contains controls that allow the user to navigate to other records, and can be displayed at the top, the bottom, or both the top and bottom of the control. Use the property to programmatically access the object that represents the bottom pager row in the control.

  The property is available only after the control creates the bottom pager row in the event.

  This property is commonly used when you need to programmatically manipulate the bottom pager row, for example when adding custom content. Any modification to the property must be performed after the object that represents the bottom pager row has been created; otherwise, the control overwrites any changes.

  Gets the object that represents the pager row displayed at the bottom of the control.

  2.0.0.0
- Property
  System.ComponentModel.Localizable(true)
  System.ComponentModel.DefaultValue("")
  System.String To be added.

  Use the property to specify the text to render in an HTML caption element in a control. The text that you specify provides assistive technology devices with a description of the table that can be used to make the control more accessible.

  Additional accessibility support for the control is provided by the property. Use the property to specify the alignment of the HTML caption element in a control.

  The value of this property, when set, can be saved automatically to a resource file by using a designer tool. For more information, see and ASP.NET Globalization and Localization.

  Gets or sets the text to render in an HTML caption element in a control. This property is provided to make the control more accessible to users of assistive technology devices.

  2.0.0.0
- Property
  System.ComponentModel.DefaultValue(System.Web.UI.WebControls.TableCaptionAlign.NotSet)
  System.Web.UI.WebControls.TableCaptionAlign To be added.

  Use the property to specify the horizontal or vertical position of the HTML caption element in a control. This property is provided to make the control more accessible to users of assistive technology devices.

  This property is set using one of the enumeration values. The following table lists the possible values.

  Value

  Description

  TableCaptionAlign.Bottom

  The caption element is aligned with the bottom of the table.

  TableCaptionAlign.Left

  The caption element is aligned with the left side of the table.

  TableCaptionAlign.NotSet

  The caption element's alignment is not set.

  TableCaptionAlign.Right

  The caption element is aligned with the right side of the table.

  TableCaptionAlign.Top

  The caption element is aligned with the top of the table.

  When this property is set to TableCaptionAlign.NotSet, the default value of the browser is used.

  Additional accessibility support for the control is provided by the property. Use the property to specify the text to render in an HTML caption element in a control.

  Gets or sets the horizontal or vertical position of the HTML caption element in a control. This property is provided to make the control more accessible to users of assistive technology devices.

  2.0.0.0
- Property
  System.ComponentModel.DefaultValue(-1)
  System.Int32 To be added.

  Use the property to control the spacing between the contents of a cell and the cell's border. The padding amount specified is added to all four sides of the cell.

  All cells in the same column of a control have the same width. The padding amount is applied to the widest cell and all other cells in the column are adjusted to that cell width. Similarly, all cells in the same row have the same height. The padding amount is applied to the tallest cell in the row and all other cells in the row are adjusted to that cell height. Individual cell sizes cannot be specified.

  To adjust the spacing between cells, use the property.

  When this property is not set, the default value of the browser is used.

  Gets or sets the amount of space between the contents of a cell and the cell's border.

  2.0.0.0
- Property
  System.ComponentModel.DefaultValue(0)
  System.Int32 To be added.

  Use the property to control the spacing between adjacent cells in the control. This spacing is applied both vertically and horizontally. The cell spacing is uniform for the entire control. Individual cell spacing between rows or columns cannot be specified.

  If you set this property to a value greater than 0, and then set the property to a value that displays the cell borders, a gap is displayed between the borders of adjacent cells. In this situation, the property controls the size of the gap.

  To adjust the spacing between the contents of a cell and the cell's border, use the property.

  Gets or sets the amount of space between cells.

  2.0.0.0
- Method
  System.Void ``

  Use the method to programmatically switch the control between edit, insert, and read-only modes. This method also updates the property with the specified mode. The following table lists the different mode values.

  Mode

  Description

  FormViewMode.Edit

  The control is in edit mode, which allows the user to update the values of a record.

  FormViewMode.Insert

  The control is in insert mode, which allows the user to add a new record to the data source.

  FormView.ReadOnly

  The control is in read-only mode, which is the normal display mode.

  The and events are not raised when this method is called.

  Switches the control to the specified data-entry mode.

  One of the enumeration values. 2.0.0.0
- Method
  System.Int32 `` `` To be added.

  The method is a helper method called by the control to create the control hierarchy for the control. When the parameter is true, data binding is performed before the control hierarchy is created.

  Creates the control hierarchy used to render the control with the specified data source.

  The number of items created from the data source.

  true to indicate that the control hierarchy is created directly from the data source; false to indicate the control hierarchy is created from the view state. 2.0.0.0
- Method
  System.Web.UI.WebControls.Style

  The method is a helper method called by the control to create its default table style object. In addition to setting the default style of a object, this method also sets the property to 0.

  Creates a default table style object for the control.

  A that contains the default table style for the control.

  2.0.0.0
- Method
  System.Web.UI.DataSourceSelectArguments

  The method is a helper method called by the control to create the object that contains the arguments passed to the data source. In this implementation, the object contains the arguments for paging operations.

  Creates the object that contains the arguments that are passed to the data source for processing.

  A that contains the arguments that are passed to the data source.

  2.0.0.0
- Method
  System.Web.UI.WebControls.FormViewRow `` `` `` To be added.

  The method is a helper method called by the control to create a object used to represent a row within the control.

  Creates a object using the specified item index, row type, and row state.

  A with the specified item index, row type, and row state.

  One of the enumeration values. A bitwise combination of the enumeration values. 2.0.0.0
- Method
  System.Web.UI.WebControls.Table

  The method is a helper method called by the control to create a table that acts as the container for the control.

  Creates the containing table for the control.

  A that represents the containing table for the control.

  2.0.0.0
- Property
  System.ComponentModel.Browsable(false)
  System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)
  System.Web.UI.WebControls.FormViewMode To be added.

  Use the property to determine whether the control is in edit, insert, or read-only mode. The following table lists the different mode values.

  Mode

  Description

  FormViewMode.Edit

  The control is in edit mode, which allows the user to update the values of a record.

  FormViewMode.Insert

  The control is in insert mode, which allows the user to add a new record to the data source.

  FormView.ReadOnly

  The control is in read-only mode, which is the normal display mode.

  This value is normally set automatically by the control when the New, Update, Insert, Delete, or Cancel command button is clicked. When the control changes modes in response to an action, the events in the following table are raised. This allows you to create a custom event handler that performs the appropriate routine when the event occurs.

  Event

  Description

  Occurs when the control changes modes, but after the mode changes. This event is commonly used to perform a task whenever the control changes modes.

  Occurs when the control changes modes, but before the mode changes. This event is commonly used to cancel the mode change.

  Note These events are not raised when you change the mode programmatically by using the method.

  Gets the current data-entry mode of the control.

  2.0.0.0
- Method
  System.Void

  Use the method to bind data from a data source to the control. This method resolves all data-binding expressions in the active template of the control.

  Binds the data source to the control.

  2.0.0.0
- Property
  System.ComponentModel.Browsable(false)
  System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)
  System.Object To be added.

  Use the property to access the data item bound to the control. The data item is often used to access the field values of the current record directly. The type of the returned by this property varies depending on the data source. For example, when a control is bound to the control, a object is returned.

  This property is available only after data binding has occurred. Before data binding occurs, this property returns null. This property is also not applicable when the control is in insert mode and returns null.

  Gets the data item bound to the control.

  2.0.0.0
- Property
  System.ComponentModel.Browsable(false)
  System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)
  System.Int32 To be added.

  Use the property to determine the number of data items contained in the data source. This property contains the same value as the property.

  Gets the number of data items in the data source.

  2.0.0.0
- Property
  System.ComponentModel.Browsable(false)
  System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)
  System.Int32 To be added.

  Use the property to determine the index of the data item bound to the control from the data source. This property contains the same value as the property.

  This property is not applicable when the control is in insert mode. When the control is in insert mode, the property returns -1.

  Gets the index of the data item bound to the control from the data source.

  2.0.0.0
- Property
  System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)
  System.ComponentModel.Browsable(false)
  System.Web.UI.WebControls.DataKey To be added.

  When the property is set, the control automatically creates a object that contains the key/value pairs of the field or fields listed in the property for the current record. Use the property to get this object. This property is commonly used to obtain the keys and their corresponding values for the fields specified in the property.

  As a shortcut, you can also use the property to determine the value of the first key field listed in the property.

  Gets a object that represents the primary key of the displayed record.

  2.0.0.0
- Property
  System.ComponentModel.Editor("System.Web.UI.Design.WebControls.DataFieldEditor, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a", "System.Drawing.Design.UITypeEditor, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
  System.ComponentModel.TypeConverter(typeof(System.Web.UI.WebControls.StringArrayConverter))
  System.ComponentModel.DefaultValue(null)
  System.String[] To be added.

  Use the property to specify a comma-separated list of field names that represent the primary key of the data source. When the property is set, the control automatically creates a object that contains the key/value pairs of the field or fields listed in the property for the current record. The object is then stored in the property.

  You must set the property for the built-in updating, deleting, and inserting features of the control to work.

  Gets or sets an array that contains the names of the key fields for the data source.

  2.0.0.0
- Property
  System.ComponentModel.DefaultValue(System.Web.UI.WebControls.FormViewMode.ReadOnly)
  System.Web.UI.WebControls.FormViewMode To be added.

  Use the property to specify whether the control returns to edit, insert, or read-only mode after an update, insert, or cancel operation is performed. By default, the control returns to read-only mode; however, you can keep the control in edit or insert mode by setting this property to the appropriate value. The following table lists the different mode values.

  Mode

  Description

  FormViewMode.Edit

  The control is in edit mode, which allows the user to update the values of a record.

  FormViewMode.Insert

  The control is in insert mode, which allows the user to add a new record to the data source.

  FormViewMode.ReadOnly

  The control is in read-only mode, which is the normal display mode.

  This property is commonly used when the control has a single purpose, such as only to insert or edit records.

  Gets or sets the data-entry mode to which the control returns after an update, insert, or cancel operation.

  2.0.0.0
- Method
  System.Void

  Use the method to programmatically delete the current record in the control from the data source. This method is commonly used when you need to delete the current record from outside of the control, such as from a different control on the page. Calling this method also raises the and events.

  Deletes the current record in the control from the data source.

  2.0.0.0
- Property
  System.ComponentModel.Browsable(false)
  System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)
  System.Web.UI.TemplateContainer(typeof(System.Web.UI.WebControls.FormView), System.ComponentModel.BindingDirection.TwoWay)
  System.ComponentModel.DefaultValue(null)
  System.Web.UI.ITemplate To be added.

  The control renders a different template for the data row based on the current mode of the control (specified by the property). The following table shows which template is used for each mode.

  Mode

  Template rendered

  Edit

  Insert

  Read-only

  Use the property to define your own user interface (UI) for the data row when the control is in edit mode. The edit item template usually contains the input controls for the user to update the values of an existing record, as well as command buttons to update the record and to cancel the update operation.

  To specify the custom template, first place <EditItemTemplate> tags between the opening and closing tags of the control. You can then list the contents of the template between the opening and closing <EditItemTemplate> tags. By using a two-way binding expression, you can associate a field with an input control. This allows the control to automatically display the original field value in the associated input control in edit mode. When a record is updated, the control automatically extracts the updated field value from the associated input control. For more information on two-way binding expressions, see ASP.NET Data Binding. To create command buttons that perform the built-in cancel and update operations, add a command button control to the template with its CommandName property set to one of the values listed in the following table.

  Command button type

  CommandName value

  Cancel

  "Cancel"

  Update

  "Update"

  You can control the appearance of the item template by using the property.

  Gets or sets the custom content for an item in edit mode.

  2.0.0.0
- Property
  System.ComponentModel.DefaultValue(null)
  System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)
  System.ComponentModel.NotifyParentProperty(true)
  System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)
  System.Web.UI.WebControls.TableItemStyle To be added.

  Use the property to control the appearance of the data row when a control is in edit mode. When the control is in edit mode, the data row displays the user-defined content specified by the property. This property is read-only; however, you can set the properties of the object it returns. The properties can be set declaratively using one of the following methods:

  Place an attribute in the opening tag of the control in the form , where is a property of the object (for example, EditRowStyle-ForeColor).

  Nest an <EditRowStyle> element between the opening and closing tags of the control.

  The properties can also be set programmatically in the form (for example, EditRowStyle.ForeColor). Common settings usually include a custom background color, foreground color, and font properties.

  Gets a reference to the object that allows you to set the appearance of the data row when a control is in edit mode.

  2.0.0.0
- Property
  System.ComponentModel.DefaultValue(null)
  System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)
  System.ComponentModel.NotifyParentProperty(true)
  System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)
  System.Web.UI.WebControls.TableItemStyle To be added.

  Use the property to control the appearance of the empty data row in a control. The empty data row is displayed when the data source that is bound to the control does not contain any records. This property is read-only; however, you can set the properties of the object it returns. The properties can be set declaratively using one of the following methods:

  Place an attribute in the opening tag of the control in the form , where is a property of the object (for example, EmptyDataRowStyle-ForeColor).

  Nest an <EmptyDataRowStyle> element between the opening and closing tags of the control.

  The properties can also be set programmatically in the form (for example, EmptyDataRowStyle.ForeColor). Common settings usually include a custom background color, foreground color, and font properties.

  Gets a reference to the object that allows you to set the appearance of the empty data row displayed when the data source bound to a control does not contain any records.

  2.0.0.0
- Property
  System.ComponentModel.Browsable(false)
  System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)
  System.Web.UI.TemplateContainer(typeof(System.Web.UI.WebControls.FormView), System.ComponentModel.BindingDirection.OneWay)
  System.ComponentModel.DefaultValue(null)
  System.Web.UI.ITemplate To be added.

  The empty data row is displayed in a control when the data source that is bound to the control does not contain any records. You can define your own custom user interface (UI) for the empty data row by using the property. To specify a custom template for the empty data row, first place <EmptyDataTemplate> tags between the opening and closing tags of the control. You can then list the contents of the template between the opening and closing <EmptyDataTemplate> tags. To control the style of the empty data row, use the property. Alternatively, you can use the built-in UI for the empty data row by setting the property instead of this property.

  If both the and properties are set, the property takes precedence.

  Gets or sets the user-defined content for the empty data row rendered when a control is bound to a data source that does not contain any records.

  2.0.0.0
- Property
  System.ComponentModel.DefaultValue("")
  System.ComponentModel.Localizable(true)
  System.String To be added.

  The empty data row is displayed in a control when the data source that is bound to the control does not contain any records. Use the property to specify the text to display in the empty data row. To control the style of the empty data row, use the property. Alternatively, you can define your own custom user interface (UI) for the empty data row by setting the property instead of this property.

  If both the and properties are set, the property takes precedence.

  The value of this property, when set, can be saved automatically to a resource file by using a designer tool. For more information, see and ASP.NET Globalization and Localization.

  Gets or sets the text to display in the empty data row rendered when a control is bound to a data source that does not contain any records.

  2.0.0.0
- Method
  System.Void

  The method is a helper method used by the class to make certain that the control is bound to data when appropriate. The method is usually called during the method to bind the control to the data source when the data-bound control is not yet bound, but requires data binding. This version of the method has been overridden to prevent data binding from occurring when the control is in insert mode.

  Makes certain that the control is bound to data when appropriate.

  2.0.0.0
- Method
  System.Void `` ``

  The method is a helper method called by the control to retrieve the values of each field declared within the data row. Because the data row displays a different template based on the current mode, this method retrieves only the field values declared in the template that corresponds to the current mode. The following table shows the available modes and the corresponding templates.

  Mode

  Template

  Insert

  Edit

  Read-only

  You can specify whether the extracted values include the key field or fields by using the parameter.

  Retrieves the values of each field declared within the data row and stores them in the specified object.

  An used to store the field values of the current data item. true to include key fields; otherwise, false. 2.0.0.0
- Property
  System.ComponentModel.Browsable(false)
  System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)
  System.Web.UI.WebControls.FormViewRow To be added.

  The footer row is displayed at the bottom of the control when the or property is set. Use the property to programmatically access the object that represents the footer row.

  The property is available only after the control creates the footer row in the event.

  This property is commonly used when you need to programmatically manipulate the footer row, for example when adding custom content. Any modification to the property must be performed after the control has been rendered; otherwise, the control overwrites any changes.

  To control the style of the footer row, use the property.

  Gets the object that represents the footer row in a control.

  2.0.0.0
- Property
  System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)
  System.ComponentModel.DefaultValue(null)
  System.ComponentModel.NotifyParentProperty(true)
  System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)
  System.Web.UI.WebControls.TableItemStyle To be added.

  The footer row is displayed at the bottom of the control when the or property is set. Use the property to control the appearance of the footer row in a control. This property is read-only; however, you can set the properties of the object it returns. The properties can be set declaratively using one of the following methods:

  Place an attribute in the opening tag of the control in the form , where is a property of the object (for example, FooterStyle-ForeColor).

  Nest a <FooterStyle> element between the opening and closing tags of the control.

  The properties can also be set programmatically in the form (for example, FooterStyle.ForeColor). Common settings usually include a custom background color, foreground color, and font properties.

  Gets a reference to the object that allows you to set the appearance of the footer row in a control.

  2.0.0.0
- Property
  System.ComponentModel.Browsable(false)
  System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)
  System.Web.UI.TemplateContainer(typeof(System.Web.UI.WebControls.FormView), System.ComponentModel.BindingDirection.OneWay)
  System.ComponentModel.DefaultValue(null)
  System.Web.UI.ITemplate To be added.

  The footer row is displayed at the bottom of the control when the or property is set. You can define your own custom user interface (UI) for the footer row by using the property. To specify a custom template for the footer row, first place <FooterTemplate> tags between the opening and closing tags of the control. You can then list the contents of the template between the opening and closing <FooterTemplate> tags. To control the style of the footer row, use the property. Alternatively, you can simply display text in the footer row by setting the property instead of this property.

  If both the and properties are set, the property takes precedence.

  Gets or sets the user-defined content for the footer row in a control.

  2.0.0.0
- Property
  System.ComponentModel.DefaultValue("")
  System.ComponentModel.Localizable(true)
  System.String To be added.

  The footer row is displayed at the bottom of the control when the or property is set. Use the property to specify the text to display in the footer row. To control the style of the footer row, use the property. Alternatively, you can define your own custom user interface (UI) for the footer row by setting the property instead of this property.

  If both the and properties are set, the property takes precedence.

  The value of this property, when set, can be saved automatically to a resource file by using a designer tool. For more information, see and ASP.NET Globalization and Localization.

  Gets or sets the text to display in the footer row of a control.

  2.0.0.0
- Property
  System.ComponentModel.DefaultValue(System.Web.UI.WebControls.GridLines.None)
  System.Web.UI.WebControls.GridLines To be added.

  Use the property to specify the gridline style for a control. The following table lists the available styles.

  Style

  Description

  GridLines.None

  No gridlines are displayed.

  GridLines.Horizontal

  Displays the horizontal gridlines only.

  GridLines.Vertical

  Displays the vertical gridlines only.

  GridLines.Both

  Displays both the horizontal and vertical gridlines.

  Gets or sets the gridline style for a control.

  2.0.0.0
- Property
  System.ComponentModel.Browsable(false)
  System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)
  System.Web.UI.WebControls.FormViewRow To be added.

  The header row is displayed at the top of the control when the or property is set. Use the property to programmatically access the object that represents the header row.

  The property is available only after the control creates the header row in the event.

  This property is commonly used when you need to programmatically manipulate the header row, for example, when adding custom content. Any modification to the property must be performed after the control has been rendered; otherwise, the control overwrites any changes.

  Gets the object that represents the header row in a control.

  2.0.0.0
- Property
  System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)
  System.ComponentModel.DefaultValue(null)
  System.ComponentModel.NotifyParentProperty(true)
  System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)
  System.Web.UI.WebControls.TableItemStyle To be added.

  The header row is displayed at the top of the control when the or property is set. Use the property to control the appearance of the header row in a control. This property is read-only; however, you can set the properties of the object it returns. The properties can be set declaratively using one of the following methods:

  Place an attribute in the opening tag of the control in the form , where is a property of the object (for example, HeaderStyle-ForeColor).

  Nest a <HeaderStyle> element between the opening and closing tags of the control.

  The properties can also be set programmatically in the form (for example, HeaderStyle.ForeColor). Common settings usually include a custom background color, foreground color, and font properties.

  Gets a reference to the object that allows you to set the appearance of the header row in a control.

  2.0.0.0
- Property
  System.ComponentModel.Browsable(false)
  System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)
  System.Web.UI.TemplateContainer(typeof(System.Web.UI.WebControls.FormView), System.ComponentModel.BindingDirection.OneWay)
  System.ComponentModel.DefaultValue(null)
  System.Web.UI.ITemplate To be added.

  The header row is displayed at the top of the control when the or property is set. You can define your own custom user interface (UI) for the header row by using the property. To specify a custom template for the header row, first place <HeaderTemplate> tags between the opening and closing tags of the control. You can then list the contents of the template between the opening and closing <HeaderTemplate> tags. To control the style of the header row, use the property. Alternatively, you can simply display text in the header row by setting the property instead of this property.

  If both the and properties are set, the property takes precedence.

  Gets or sets the user-defined content for the header row in a control.

  2.0.0.0
- Property
  System.ComponentModel.DefaultValue("")
  System.ComponentModel.Localizable(true)
  System.String To be added.

  The header row is displayed at the top of the control when the or property is set. Use the property to specify the text to display in the header row. To control the style of the header row, use the property. Alternatively, you can define your own custom user interface (UI) for the header row by setting the property instead of this property.

  If both the and properties are set, the property takes precedence.

  The value of this property, when set, can be saved automatically to a resource file by using a designer tool. For more information, see and ASP.NET Globalization and Localization.

  Gets or sets the text to display in the header row of a control.

  2.0.0.0
- Property
  System.ComponentModel.DefaultValue(System.Web.UI.WebControls.HorizontalAlign.NotSet)
  System.ComponentModel.Category("Layout")
  System.Web.UI.WebControls.HorizontalAlign To be added.

  Use the property to specify the horizontal alignment of a control within the page. The following table lists the different horizontal alignment styles.

  HorizontalAlign value

  Description

  HorizontalAlign.NotSet

  The horizontal alignment of the control has not been set.

  HorizontalAlign.Left

  The control is left-aligned on the page.

  HorizontalAlign.Center

  The control is centered on the page.

  HorizontalAlign.Right

  The control is right-aligned on the page.

  HorizontalAlign.Justify

  The control is aligned with both the left and right margins of the page.

  Gets or sets the horizontal alignment of a control on the page.

  2.0.0.0
- Method
  System.Void `` `` To be added.

  The method is a helper method called by the control to create the pager row. It creates a object that contains the navigation controls using the properties of the object contained in the parameter. The cell is then added to the row specified by the parameter.

  Creates the pager row for the control.

  The that contains the pager row. 2.0.0.0
- Method
  System.Void ``

  The method is a helper method called by the control to initialize the specified object. The object is initialized based on the row type and row state specified by its and properties, respectively. The appropriate content is then added to the object. The following table describes how each row type is initialized.

  Row type

  Description

  Data row

  The contents of the , , or property are added to the object, depending on the value of the property.

  Empty data row

  The value of the property or the contents of the property is added to the object, depending on which property is set. If both properties are set, the property takes precedence.

  Footer row

  The value of the property or the contents of the property is added to the object, depending on which property is set. If both properties are set, the property takes precedence.

  Header row

  The value of the property or the contents of the property is added to the object, depending on which property is set. If both properties are set, the property takes precedence.

  This method does not initialize the pager row. To create the pager row, use the method.

  Initializes the specified object.

  The to initialize. 2.0.0.0
- Method
  System.Void ``

  When the control is in insert mode, use the method to programmatically insert the current record in the data source. This method is commonly used when you need to insert the current record from outside of the control, such as from a different control on the page.

  The control must be in insert mode when this method is called; otherwise, an is thrown.

  To specify whether page validation is performed before the insert operation, use the parameter. Calling this method also raises the and events.

  Inserts the current record in the data source.

  true to perform page validation when the method is called; otherwise, false. 2.0.0.0
- Property
  System.ComponentModel.Browsable(false)
  System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)
  System.Web.UI.TemplateContainer(typeof(System.Web.UI.WebControls.FormView), System.ComponentModel.BindingDirection.TwoWay)
  System.ComponentModel.DefaultValue(null)
  System.Web.UI.ITemplate To be added.

  The control renders a different template for the data row based on the current mode of the control (specified by the property). The following table shows which template is used for each mode.

  Mode

  Template rendered

  Edit

  Insert

  Read-only

  Use the property to define your own user interface (UI) for the data row when the control is in insert mode. The insert item template usually contains the input controls for the user to enter the values for the new record, as well as command buttons to insert the record and to cancel the insert operation.

  To specify the custom template, first place <InsertItemTemplate> tags between the opening and closing tags of the control. You can then list the contents of the template between the opening and closing <InsertItemTemplate> tags. By using a two-way binding expression, you can associate a field with an input control. When a record is inserted, the control automatically extracts the field value from the associated input control. For more information on two-way binding expressions, see ASP.NET Data Binding. To create command buttons that perform the built-in cancel and insert operations, add a command button control to the template with its CommandName property set to one of the values listed in the following table.

  Command button type

  CommandName value

  Cancel

  "Cancel"

  Insert

  "Insert"

  You can control the appearance of the item template by using the property.

  Gets or sets the custom content for an item in insert mode.

  2.0.0.0
- Property
  System.ComponentModel.DefaultValue(null)
  System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)
  System.ComponentModel.NotifyParentProperty(true)
  System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)
  System.Web.UI.WebControls.TableItemStyle To be added.

  Use the property to control the appearance of the data row when a control is in insert mode. When the control is in insert mode, the data row displays the user-defined content specified by the property. This property is read-only; however, you can set the properties of the object it returns.

  The properties can be set declaratively using one of the following methods:

  Place an attribute in the opening tag of the control in the form , where is a property of the object (for example, InsertRowStyle-ForeColor).

  Nest an <InsertRowStyle> element between the opening and closing tags of the control.

  The properties can also be set programmatically in the form (for example, InsertRowStyle.ForeColor). Common settings usually include a custom background color, foreground color, and font properties.

  Gets a reference to the object that allows you to set the appearance of the data row in a control when the control is in insert mode.

  2.0.0.0
- Method
  System.Boolean ``

  The method is a helper method called by the control to determine whether the specified data type can be bound to a field in the control. The control supports the following data types:

  All primitive data types, such as , , , and so on.

  Determines whether the specified data type can be bound to a field in the control.

  true if the specified data type can be bound to a field in the control; otherwise, false.

  A that represents the data type to check. 2.0.0.0
- Event
  System.Web.UI.WebControls.FormViewCommandEventHandler

  The event is raised when a button within the control is clicked. This allows you to provide an event-handling method that performs a custom routine whenever this event occurs.

  Buttons within a control can also invoke some of the built-in functionality of the control. To perform one of these operations, set the CommandName property of a button to one of the values in the following table.

  CommandName value

  Description

  "Cancel"

  Cancels an edit or insert operation and returns the control to the mode specified by the property. Raises the and events.

  "Delete"

  Deletes the current record. Raises the and events.

  "Edit"

  Puts the control in edit mode. Raises the and events.

  "Insert"

  Inserts the current record in the data source. Raises the and events.

  "New"

  Puts the control in insert mode. Raises the and events.

  "Page"

  Performs a paging operation. Set the CommandArgument property of the button to "First", "Last", "Next", "Prev", or a page number to specify the type of paging operation to perform. Raises the and events.

  "Update"

  Updates the current record in the data source. Raises the and events.

  Although the event is raised when a button listed in the previous table is clicked, it is recommended that you use the events listed in the table for the operation.

  A object is passed to the event-handling method, which allows you to determine the command name and command argument of the button clicked. To determine the command name and command argument, use the and properties, respectively. You can also access the control that raised the event by using the property.

  For more information about handling events, see Consuming Events.

  Occurs when a button within a control is clicked.

  2.0.0.0
- Event
  System.EventHandler

  The event is raised after all rows are created in a control. This can occur when the control is first rendered, or when the user navigates to another record. You can use this event to provide an event-handling method that performs a custom routine, such as adding to or modifying the contents of a row, whenever this event occurs.

  The event occurs before the control is bound to data. To modify the value of a bound field, use the event.

  You can access the header, footer, and pager rows in the control by using the , , , or properties, respectively. To access the data row, use the property.

  For more information about handling events, see Consuming Events.

  Occurs after all the rows are created in a control.

  2.0.0.0
- Event
  System.Web.UI.WebControls.FormViewDeletedEventHandler

  The control raises the event when a Delete button (a button with its CommandName property set to "Delete") within the control is clicked, but after the control deletes the record. This allows you to provide an event-handling method that performs a custom routine, such as checking the results of a delete operation, whenever this event occurs.

  A object is passed to the event-handling method, which allows you to determine the number of records affected and any exceptions that might have occurred. To determine the number of records affected by the delete operation, use the property. Use the property to determine whether any exceptions occurred. You can also indicate whether the exception was handled in the event-handling method by setting the property. If you want to access the name/value pairs of the key fields and non-key fields of the deleted record, use the and properties, respectively.

  For more information about handling events, see Consuming Events.

  Occurs when a Delete button within a control is clicked, but after the delete operation.

  2.0.0.0
- Event
  System.Web.UI.WebControls.FormViewDeleteEventHandler

  The control raises the event when a Delete button (a button with its CommandName property set to "Delete") within the control is clicked, but before the control deletes the record. This allows you to provide an event-handling method that performs a custom routine, such as verifying a record before deleting it, whenever this event occurs.

  A object is passed to the event-handling method, which allows you to determine the index of the record being deleted and to indicate that the delete operation should be canceled. To determine the index of a record, use the property. To cancel the delete operation, set the property to true. You can also access the key fields and non-key fields by using the and properties, respectively.

  For more information about handling events, see Consuming Events.

  Occurs when a Delete button within a control is clicked, but before the delete operation.

  2.0.0.0
- Event
  System.Web.UI.WebControls.FormViewInsertedEventHandler

  The control raises the event when an Insert button (a button with its CommandName property set to "Insert") within the control is clicked, but after the control inserts the record. This allows you to provide an event-handling method that performs a custom routine, such as checking the results of an insert operation, whenever this event occurs.

  A object is passed to the event-handling method, which allows you to determine the number of records affected and any exceptions that might have occurred. To determine the number of records affected by the insert operation, use the property. Use the property to determine whether any exceptions occurred. You can also indicate whether the exception was handled in the event-handling method by setting the property. If you need to access the values of the inserted record, use the property.

  By default, the control returns to the mode specified by the property after an insert operation. To keep the control in insert mode, set the property to true.

  For more information about handling events, see Consuming Events.

  Occurs when an Insert button within a control is clicked, but after the insert operation.

  2.0.0.0
- Event
  System.Web.UI.WebControls.FormViewInsertEventHandler

  The control raises the event when an Insert button (a button with its CommandName property set to "Insert") within the control is clicked, but before the control inserts the record. This allows you to provide an event-handling method that performs a custom routine, such as HTML encoding the values of a record before inserting it in the data source, whenever this event occurs.

  A object is passed to the event-handling method, which allows you to determine the value of an optional command argument sent to the control and to indicate that the insert operation should be canceled. The command argument value corresponds to the CommandArgument property of the Insert button. When the CommandArgument property of the Insert button is set, use the property to determine the value of the command argument. To cancel the insert operation, set the property to true. You can also read or modify the field values for the new record by using the property.

  For more information about handling events, see Consuming Events.

  Occurs when an Insert button within a control is clicked, but before the insert operation.

  2.0.0.0
- Property
  System.ComponentModel.Browsable(false)
  System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)
  System.Web.UI.TemplateContainer(typeof(System.Web.UI.WebControls.FormView), System.ComponentModel.BindingDirection.TwoWay)
  System.ComponentModel.DefaultValue(null)
  System.Web.UI.ITemplate To be added.

  The control renders a different template for the data row based on the current mode of the control (specified by the property). The following table shows which template is used for each mode.

  Mode

  Template rendered

  Edit

  Insert

  Read-only

  Use the property to define your own user interface (UI) for the data row when the control is in read-only mode. The item template usually contains controls to display the field values of a record, as well as command buttons to edit, insert, and delete a record.

  To specify the custom template, first place <ItemTemplate> tags between the opening and closing tags of the control. You can then list the contents of the template between the opening and closing <ItemTemplate> tags. To display the field values of the data source bound to the control, use a data-binding expression. For more information on data-binding expressions, see Data Binding Expression Syntax. To create command buttons that perform the built-in delete, edit, and new record operations, add a command button control to the template with its CommandName property set to one of the values listed in the following table.

  Command button type

  CommandName value

  Delete

  "Delete"

  Edit

  "Edit"

  New

  "New"

  You can control the appearance of the item template by using the property.

  Gets or sets the custom content for the data row in a control when the control is in read-only mode.

  2.0.0.0
- Event
  System.Web.UI.WebControls.FormViewUpdatedEventHandler

  The control raises the event when an Update button (a button with its CommandName property set to "Update") within the control is clicked, but after the control updates the record. This allows you to provide an event-handling method that performs a custom routine, such as checking the results of an update operation, whenever this event occurs.

  A object is passed to the event-handling method, which allows you to determine the number of records affected and any exceptions that might have occurred. To determine the number of records affected by the update operation, use the property. Use the property to determine whether any exceptions occurred. You can also indicate whether the exception was handled in the event-handling method by setting the property. If you need to access the key field values for the updated record, use the property. The original and updated non-key field values can be accessed using the and properties, respectively.

  By default, the control returns to the mode specified by the property after an update operation. To keep the control in edit mode, set the property to true.

  For more information about handling events, see Consuming Events.

  Occurs when an Update button within a control is clicked, but after the update operation.

  2.0.0.0
- Event
  System.Web.UI.WebControls.FormViewUpdateEventHandler

  The control raises the event when an Update button (a button with its CommandName property set to "Update") within the control is clicked, but before the control updates the record. This allows you to provide an event-handling method that performs a custom routine, such as HTML encoding the values of a record before updating it in the data source, whenever this event occurs.

  A object is passed to the event-handling method, which allows you to determine the value of an optional command argument sent to the control and to indicate that the update operation should be canceled. The command argument value corresponds to the CommandArgument property of the Update button. When the CommandArgument property of the Update button is set, use the property to determine the value of the command argument. To cancel the update operation, set the property to true. You can also read or modify the new values entered by the user by using the and properties. The property contains the key fields, while the property contains the non-key fields. If you need to access the original non-key field values, use the property.

  For more information about handling events, see Consuming Events.

  Occurs when an Update button within a control is clicked, but before the update operation.

  2.0.0.0
- Method
  2.0.0.0
  System.Void `` To be added.

  The method is used to load the state of the control properties that need to be persisted, even when the property is set to false.

  This method is used primarily by control developers when extending the control.

  Loads the state of the control properties that need to be persisted, even when the property is set to false.

- Method
  System.Void ``

  The method is used to load the previously saved view state of the control.

  This method is used primarily by control developers when extending the control.

  Loads the previously saved view state of the control.

  An that represents the state of the control. 2.0.0.0
- Event
  System.EventHandler

  The event is raised when a control attempts to switch between edit, insert, and read-only mode, but after the mode actually changes. This allows you to provide an event-handling method that performs a custom routine, such as synchronizing the control with another control, whenever this event occurs.

  For more information about handling events, see Consuming Events.

  Occurs when the control switches between edit, insert, and read-only mode, but after the mode has changed.

  2.0.0.0
- Event
  System.Web.UI.WebControls.FormViewModeEventHandler

  The event is raised when a control attempts to switch between edit, insert, and read-only mode, but before the mode actually changes. This allows you to provide an event-handling method that performs a custom routine, such as configuring the control for a specific mode or canceling the mode change, whenever this event occurs.

  A object is passed to the event-handling method, which allows you to determine the mode to which the control is switching, to determine whether the event was raised as a result of the user canceling an edit operation, or to indicate that an insert operation should be canceled. To determine the new mode, use the property. You can also use the property to switch to an alternate mode by setting it to one of the enumeration values. Use the property to determine whether the user canceled an edit operation. To cancel an insert operation, set the property to true.

  For more information about handling events, see Consuming Events.

  Occurs when the control switches between edit, insert, and read-only mode, but before the mode changes.

  2.0.0.0
- Method
  System.Boolean `` ``

  The method is used by the control to optionally handle events passed up through the control hierarchy by the method. It determines whether to handle an event by examining the properties of the object contained in the parameter. When an event needs to be handled, the method performs the appropriate action. Other events are ignored and passed up the control hierarchy. This method indicates whether to pass the event further up the control hierarchy through its return value.

  The control overrides the base implementation of this method to perform the appropriate action when one of the buttons recognized by the control is clicked. The following table lists the command buttons that the control recognizes.

  Button

  CommandName value

  Description

  Cancel

  "Cancel"

  Used in updating or inserting operations to cancel the operation and to discard the values entered by the user. The control then returns to the mode specified by the property.

  Delete

  "Delete"

  Used in deleting operations to delete the displayed record from the data source. Raises the and events.

  Edit

  "Edit"

  Used in updating operations to put the control in edit mode. The content specified in the property is displayed for the data row.

  Insert

  "Insert"

  Used in inserting operations to attempt to insert a new record in the data source with the values provided by the user. Raises the and events.

  New

  "New"

  Used in inserting operations to put the control in insert mode. The content specified in the property is displayed for the data row.

  Page

  "Page"

  Used in paging operations to represent a button in the pager row that performs paging. To specify the paging operation, set the CommandArgument property of the button to "Next", "Prev", "First", "Last", or the index of the page to which to navigate. Raises the and events.

  This type of button is typically used only in the pager template.

  Update

  "Update"

  Used in updating operations to attempt to update the displayed record in the data source with the values provided by the user. Raises the and events.

  This version of the method returns true when one of these buttons is handled. For more information about event bubbling, see Events and Delegates.

  Handles an event passed up through the control hierarchy.

  true to indicate the event should be passed further up the control hierarchy; otherwise, false.

  The source of the event. An that contains the event data. 2.0.0.0
- Method
  2.0.0.0
  System.Void ``

  The method is called by the control to raise the event. It is generally used by control developers when extending the class.

  Raising an event invokes the event handler through a delegate. For more information, see Raising an Event.

  The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.

  Raises the event.

  An that contains the event data.
- Method
  System.Void ``

  The method is called by the control to raise the event. It is generally used by control developers when extending the class.

  Raising an event invokes the event handler through a delegate. For more information, see Raising an Event.

  The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.

  Raises the event.

  A that contains the event data. 2.0.0.0
- Method
  System.Void ``

  The method is called by the control to raise the event. It is generally used by control developers when extending the class.

  Raising an event invokes the event handler through a delegate. For more information, see Raising an Event.

  The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.

  Raises the event.

  An that contains the event data. 2.0.0.0
- Method
  System.Void ``

  The method is called by the control to raise the event. It is generally used by control developers when extending the class.

  Raising an event invokes the event handler through a delegate. For more information, see Raising an Event.

  The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.

  Raises the event.

  A that contains the event data. 2.0.0.0
- Method
  System.Void ``

  The method is called by the control to raise the event. It is generally used by control developers when extending the class.

  Raising an event invokes the event handler through a delegate. For more information, see Raising an Event.

  The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.

  Raises the event.

  A that contains the event data. 2.0.0.0
- Method
  System.Void ``

  The method is called by the control to raise the event. It is generally used by control developers when extending the class.

  Raising an event invokes the event handler through a delegate. For more information, see Raising an Event.

  The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.

  Raises the event.

  A that contains the event data. 2.0.0.0
- Method
  System.Void ``

  The method is called by the control to raise the event. It is generally used by control developers when extending the class.

  Raising an event invokes the event handler through a delegate. For more information, see Raising an Event.

  The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.

  Raises the event.

  A that contains the event data. 2.0.0.0
- Method
  System.Void ``

  The method is called by the control to raise the event. It is generally used by control developers when extending the class.

  Raising an event invokes the event handler through a delegate. For more information, see Raising an Event.

  The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.

  Raises the event.

  A that contains the event data. 2.0.0.0
- Method
  System.Void ``

  The method is called by the control to raise the event. It is generally used by control developers when extending the class.

  Raising an event invokes the event handler through a delegate. For more information, see Raising an Event.

  The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.

  Raises the event.

  A that contains the event data. 2.0.0.0
- Method
  System.Void ``

  The method is called by the control to raise the event. It is generally used by control developers when extending the class.

  Raising an event invokes the event handler through a delegate. For more information, see Raising an Event.

  The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.

  Raises the event.

  An that contains the event data. 2.0.0.0
- Method
  System.Void ``

  The method is called by the control to raise the event. It is generally used by control developers when extending the class.

  Raising an event invokes the event handler through a delegate. For more information, see Raising an Event.

  The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.

  Raises the event.

  A that contains the event data. 2.0.0.0
- Method
  System.Void ``

  The method is called by the control to raise the event. It is generally used by control developers when extending the class.

  Raising an event invokes the event handler through a delegate. For more information, see Raising an Event.

  The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.

  Raises the event.

  An that contains the event data. 2.0.0.0
- Method
  System.Void ``

  The method is called by the control to raise the event. It is generally used by control developers when extending the class.

  Raising an event invokes the event handler through a delegate. For more information, see Raising an Event.

  The method also allows derived classes to handle the event without attaching a delegate. This is the preferred technique for handling the event in a derived class.

  Raises the event.

  A that contains the event data. 2.0.0.0
- Property
  System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)
  System.ComponentModel.Browsable(false)
  System.Int32 To be added.

  When the paging feature is enabled (when the property is set to true), use the property to determine the total number of records in the underlying data source.

  Because the control displays only one record at a time, this value corresponds to the total number of pages required to display every record in the data source. This value is not accurate until after data-binding occurs.

  To determine the index of the current record from the underlying data source, use the property.

  Gets the total number of pages required to display every record in the data source.

  2.0.0.0
- Property
  System.ComponentModel.DefaultValue(0)
  System.ComponentModel.Bindable(true, System.ComponentModel.BindingDirection.OneWay)
  System.Int32 To be added.

  When the paging feature is enabled (when the property is set to true), use the property to determine the index of the currently displayed record. You can also use this property to programmatically change the displayed record.

  When the paging feature is enabled, you can also use this property to determine the page number of the record displayed; however, be aware that this property is zero-based.

  To determine the total number of items in the data source, use the property.

  Gets or sets the index of the displayed page.

  2.0.0.0
- Event
  System.EventHandler

  The control raises the event when a pager button (a button with its CommandName property set to "Page") within the control is clicked, but after the control handles the paging operation. This allows you to provide an event-handling method that performs a custom routine whenever this event occurs.

  This event is not raised when you programmatically set the property.

  Pager buttons are usually located in the pager row of a control. This event is often used to synchronize a control with a control or to set the behavior of the control after a paging operation.

  For more information about handling events, see Consuming Events.

  Occurs when the value of the property changes after a paging operation.

  2.0.0.0
- Event
  System.Web.UI.WebControls.FormViewPageEventHandler

  The control raises the event when a pager button (a button with its CommandName property set to "Page") within the control is clicked, but before the control handles the paging operation. This allows you to provide an event-handling method that performs a custom routine, such as canceling the paging operation, whenever this event occurs.

  This event is not raised when you programmatically set the property.

  Pager buttons are usually located in the pager row of a control.

  A object is passed to the event-handling method, which allows you to determine the index of the page selected by the user and to indicate that the paging operation should be canceled. To determine the index of the page selected by the user, use the property. To cancel the paging operation, set the property of the object to true.

  For more information about handling events, see Consuming Events.

  Occurs when the value of the property changes before a paging operation.

  2.0.0.0
- Property
  System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)
  System.ComponentModel.NotifyParentProperty(true)
  System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)
  System.Web.UI.WebControls.PagerSettings To be added.

  Use the property to control the settings of the pager row in a control. The pager row is displayed when the paging feature is enabled (when the property is set to true), and contains the controls that allow the user to navigate to the different records in the control. This property is read-only; however, you can set the properties of the object it returns. The properties can be set declaratively in the form , where is a property of the object (for example, PagerSettings-Mode). The properties can also be set programmatically in the form (for example, PagerSettings.Mode). Common settings usually include the pager row's display mode and custom text or images for the navigation controls.

  Gets a reference to the object that allows you to set the properties of the pager buttons in a control.

  2.0.0.0
- Property
  System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)
  System.ComponentModel.NotifyParentProperty(true)
  System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)
  System.Web.UI.WebControls.TableItemStyle To be added.

  Use the property to control the appearance of the pager row in a control. The pager row is displayed when the paging feature is enabled (when the property is set to true), and contains the controls that allow the user to navigate to the different pages in the control. This property is read-only; however, you can set the properties of the object it returns. The properties can be set declaratively using one of the following methods:

  Place an attribute in the opening tag of the control in the form , where is a property of the object (for example, PagerStyle-ForeColor).

  Nest a <PagerRowStyle> element between the opening and closing tags of the control.

  The properties can also be set programmatically in the form (for example, PagerStyle.ForeColor). Common settings usually include a custom background color, foreground color, and font properties.

  Gets a reference to the object that allows you to set the appearance of the pager row in a control.

  2.0.0.0
- Property
  System.ComponentModel.Browsable(false)
  System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)
  System.Web.UI.TemplateContainer(typeof(System.Web.UI.WebControls.FormView))
  System.ComponentModel.DefaultValue(null)
  System.Web.UI.ITemplate To be added.

  A pager row is displayed in a control when the paging feature is enabled (when the property is set to true). The pager row contains the controls that allow the user to navigate to the different pages in the control. Instead of using the built-in pager row user interface (UI), you can define your own UI by using the property.

  When the property is set it overrides the built-in pager row UI.

  To specify a custom template for the pager row, first place <PagerTemplate> tags between the opening and closing tags of the control. You can then list the contents of the template between the opening and closing <PagerTemplate> tags. To control the appearance of the pager row, use the property.

  Typically, button controls are added to the pager template to perform the paging operations. The control performs a paging operation when a button control with its CommandName property set to "Page" is clicked. The button's CommandArgument property determines the type of paging operation to perform. The following table lists the command argument values supported by the control.

  CommandArgument value

  Description

  "Next"

  Navigates to the next page.

  "Prev"

  Navigates to the previous page.

  "First"

  Navigates to the first page.

  "Last"

  Navigates to the last page.

  Integer value

  Navigates to the specified page number.

  Gets or sets the custom content for the pager row in a control.

  2.0.0.0
- Method
  2.0.0.0
  System.Void ``

  The method is a helper method called by the control to bind the specified data source to the control.

  Binds the specified data source to the control.

  An that represents the data source.
- Method
  2.0.0.0
  System.Void

  The method is a helper method called by the control to set up the control hierarchy in the control before the control is rendered.

  Sets up the control hierarchy of the control.

- Method
  System.Void ``

  The page calls the method when a postback event occurs that raises the appropriate events for a control. This call occurs in the page life cycle after loading and change notification are complete, but before prerendering occurs. This method has been implemented to create a object for the events that are raised.

  This method is used primarily by control developers to extend the control.

  Raises the appropriate events for the control when it posts back to the server.

  The event argument from which to create a for the event or events that are raised. 2.0.0.0
- Method
  2.0.0.0
  System.Void ``

  The method is used to render the server control content to the client's browser using the specified object.

  Displays the control on the client.

  An that contains the output stream to render on the client.
- Property
  System.ComponentModel.Browsable(false)
  System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)
  System.Web.UI.WebControls.FormViewRow To be added.

  Use the property to programmatically access the object that represents the data row. The data row contains different content based on the template rendered for the current mode (specified by the property). You can only access the contents of the template for the current mode. The following table shows which template is used for each mode.

  Mode

  Template rendered

  Edit

  Insert

  Read-only

  The property is available only after the control creates the data row in the event.

  This property is commonly used when you need to programmatically manipulate the data row, for example when adding custom content. Any modification to the property must be performed after the control has been data-bound; otherwise, the control overwrites any changes.

  Gets the object that represents the data row in a control.

  2.0.0.0
- Property
  System.ComponentModel.DefaultValue(null)
  System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Content)
  System.ComponentModel.NotifyParentProperty(true)
  System.Web.UI.PersistenceMode(System.Web.UI.PersistenceMode.InnerProperty)
  System.Web.UI.WebControls.TableItemStyle To be added.

  Use the property to control the appearance of the data row when a control is in read-only (display) mode. When the control is in read-only mode, the data row displays the user-defined content specified by the property. This property is read-only; however, you can set the properties of the object it returns. The properties can be set declaratively using one of the following methods:

  Place an attribute in the opening tag of the control in the form , where is a property of the object (for example, RowStyle-ForeColor).

  Nest an <RowStyle> element between the opening and closing tags of the control.

  The properties can also be set programmatically in the form (for example, RowStyle.ForeColor). Common settings usually include a custom background color, foreground color, and font properties.

  Gets a reference to the object that allows you to set the appearance of the data row in a control when the control is in read-only mode.

  2.0.0.0
- Method
  2.0.0.0
  System.Object

  This method is used to save the state of the control properties that need to be persisted, even when the property is set to false.

  This method is used primarily by control developers to extend the control.

  Saves the state of the control properties that need to be persisted, even when the property is set to false.

  Returns the server control's current view state. If there is no view state associated with the control, this method returns null.

- Method
  System.Object

  The method is a helper method called by the control to save the state of the control.

  Saves the current view state of the control.

  An that contains the saved state of the control.

  2.0.0.0
- Property
  System.ComponentModel.Browsable(false)
  System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)
  System.Object To be added.

  When the property is set, the control automatically creates a object that contains the key/value pairs of the field or fields listed in the property for the current record. The object represents the primary key field or fields for the current record and is stored in the property. Instead of using the property to access the data key value, you can use the property as a shortcut.

  When the property lists multiple fields, this property returns the value of the first field listed.

  Gets the data key value of the current record in a control.

  2.0.0.0
- Property
  2.0.0.0
  System.Int32 To be added.

  This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface.

  For a description of this member, see .

- Property
  2.0.0.0
  System.Int32 To be added.

  This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface.

  For a description of this member, see .

- Method
  2.0.0.0
  System.Void ``

  The page calls the method when a postback event occurs. This call occurs in the page life cycle after loading and change notification are complete, but before the page is rendered.

  Raises events for the control when it posts back to the server.

  The argument for the event.
- Method
  2.0.0.0
  System.Web.UI.PostBackOptions `` To be added.

  The method is a helper method that is called by the control to create a object that contains the postback event options for the control. The object is typically used as a parameter for the method.

  Determines the postback event options for the control.

  The postback event options for the control.

- Property
  System.Web.UI.HtmlTextWriterTag To be added.

  The property allows the output stream to write the appropriate HTML markup for the control.

  Gets the value for the control.

  2.0.0.0
- Property
  System.ComponentModel.Browsable(false)
  System.ComponentModel.DesignerSerializationVisibility(System.ComponentModel.DesignerSerializationVisibility.Hidden)
  System.Web.UI.WebControls.FormViewRow To be added.

  When paging is enabled (when the property is set to true), an additional row called the pager row is automatically displayed in the control. The pager row contains controls that allow the user to navigate to other records, and can be displayed at the top, the bottom, or both the top and bottom of the control. Use the property to programmatically access the object that represents the top pager row in the control.

  The property is available only after the control creates the top pager row in the event.

  This property is commonly used when you need to programmatically manipulate the top pager row, for example when adding custom content. Any modification to the property must be performed after the control has been bound to data; otherwise, the control overwrites any changes.

  Gets the object that represents the pager row displayed at the top of a control.

  2.0.0.0
- Method
  System.Void

  This method is overridden to mark the starting point at which to begin tracking and saving changes to the control as part of the control's view state.

  Marks the starting point at which to begin tracking and saving view-state changes to the control.

  2.0.0.0
- Method
  System.Void ``

  When the control is in edit mode, use the method to programmatically update the current record in the data source. This method is commonly used when you need to update the current record from outside of the control, such as from a different control on the page.

  The control must be in edit mode when this method is called; otherwise, an is thrown.

  To specify whether page validation is performed before the update operation, use the parameter. Calling this method also raises the and events.

  Updates the current record in the data source.

  true to perform page validation when the method is called; otherwise false. 2.0.0.0