FormView イベント


関連項目
FormView クラスSystem.Web.UI.WebControls 名前空間
DetailsView クラス
GridView
FormViewRow
FormViewMode
AccessDataSource クラス
SqlDataSource
ObjectDataSource
FormView.AllowPaging プロパティ
FormView.CurrentMode プロパティ
FormView.DataKeyNames プロパティ
FormView.DefaultMode プロパティ
FormView.PagerStyle プロパティ
FormView.PagerSettings プロパティ
FormView.EditRowStyle プロパティ
FormView.EmptyDataRowStyle プロパティ
FormView.FooterStyle プロパティ
FormView.HeaderStyle プロパティ
FormView.InsertRowStyle プロパティ
FormView.PagerStyle プロパティ
FormView.RowStyle プロパティ
FormView.EditItemTemplate プロパティ
FormView.EmptyDataTemplate プロパティ
FormView.FooterTemplate プロパティ
FormView.HeaderTemplate プロパティ
FormView.InsertItemTemplate プロパティ
FormView.ItemTemplate プロパティ
FormView.PagerTemplate プロパティ
ItemCreated
ItemCommand
ItemDeleted
ItemDeleting
ItemInserted
ItemInserting
ItemUpdated
ItemUpdating
ModeChanged
ModeChanging
PageIndexChanged
PageIndexChanging
FormView クラス
アセンブリ: System.Web (system.web.dll 内)

<ControlValuePropertyAttribute("SelectedValue")> _ Public Class FormView Inherits CompositeDataBoundControl Implements IDataItemContainer, INamingContainer, IPostBackEventHandler, IPostBackContainer
[ControlValuePropertyAttribute("SelectedValue")] public class FormView : CompositeDataBoundControl, IDataItemContainer, INamingContainer, IPostBackEventHandler, IPostBackContainer
[ControlValuePropertyAttribute(L"SelectedValue")] public ref class FormView : public CompositeDataBoundControl, IDataItemContainer, INamingContainer, IPostBackEventHandler, IPostBackContainer

FormView コントロールは、データ ソースから単一レコードを表示するために使用されます。このコントロールは、行フィールドではなく、ユーザー定義のテンプレートを表示するという点を除いて、DetailsView コントロールに似ています。独自のテンプレートを作成すると、データの表示方法をより柔軟に制御できます。FormView コントロールは、次の機能をサポートしています。
-
SqlDataSource や ObjectDataSource などのデータ ソース コントロールへのバインド。
-
プロパティを動的に設定したり、イベントを処理したりするための、FormView オブジェクト モデルへのプログラムによるアクセス。
コンテンツを表示する FormView コントロールの場合、コントロールのさまざまな部分用にテンプレートを作成する必要があります。ほとんどのテンプレートは省略可能ですが、コントロールの構成が行われるモードについては、テンプレートを作成する必要があります。たとえば、レコードの挿入をサポートする FormView コントロールには、項目挿入テンプレートを定義する必要があります。作成できるさまざまなテンプレートの一覧を次の表に示します。
EditItemTemplate | FormView コントロールが編集モードの場合のデータ行のコンテンツを定義します。通常、このテンプレートには、ユーザーが既存のレコードの編集に使用できる入力コントロールとコマンド ボタンが含まれます。 |
EmptyDataTemplate | レコードが格納されていないデータ ソースに FormView コントロールがバインドされている場合に表示される、空のデータ行用のコンテンツを定義します。通常、このテンプレートには、データ ソースにレコードが格納されていないことをユーザーに警告するコンテンツが含まれます。 |
FooterTemplate | |
HeaderTemplate | |
ItemTemplate | FormView コントロールが読み取り専用モードの場合のデータ行のコンテンツを定義します。通常、このテンプレートには、既存のレコードの値を表示するコンテンツが含まれます。 |
InsertItemTemplate | FormView コントロールが挿入モードの場合のデータ行のコンテンツを定義します。通常、このテンプレートには、ユーザーが新規レコードの追加に使用できる入力コントロールとコマンド ボタンが含まれます。 |
PagerTemplate | ページング機能が有効になっている場合 (AllowPaging プロパティが true に設定されている場合) に表示されるページ行のコンテンツを定義します。通常、このテンプレートには、ユーザーが別のレコードへの移動に使用できるコントロールが含まれます。 |
項目テンプレート内のフィールドの値を表示するには、データ バインド式を使用します。データ バインド式の詳細については、「データ バインド式構文」を参照してください。
項目編集テンプレートと項目挿入テンプレートの入力コントロールは、双方向のバインド式を使用して、データ ソースのフィールドにバインドできます。これにより、FormView コントロールは、更新操作または挿入操作用に入力コントロールの値を自動的に取得できます。双方向のバインド式を使用すると、項目編集テンプレートの入力項目にも自動的に元のフィールド値を表示できます。双方向のバインド式の詳細については、「データベースへのバインド」を参照してください。
データへのバインド
FormView コントロールは、データ ソース コントロール (SqlDataSource、AccessDataSource、ObjectDataSource など)、または System.Collections.IEnumerable インターフェイスを実装するデータ ソース (System.Data.DataView、System.Collections.ArrayList、System.Collections.Hashtable など) にバインドできます。FormView コントロールを適切なデータ ソースの種類にバインドするには、次のいずれかの方法を使用します。
-
データ ソース コントロールにバインドするには、FormView コントロールの DataSourceID プロパティをデータ ソース コントロールの ID 値に設定します。FormView コントロールは、指定したデータ ソース コントロールに自動的にバインドされ、データ ソース コントロールの機能を利用して、挿入、更新、削除、およびページングの各機能を実行できます。データにバインドするには、この方法をお勧めします。
-
System.Collections.IEnumerable インターフェイスを実装するデータ ソースにバインドするには、プログラムによって FormView コントロールの DataSource プロパティをデータ ソースに設定してから、DataBind メソッドを呼び出します。このメソッドを使用すると、FormView コントロールは、組み込みの挿入、更新、削除、およびページングの各機能を提供しません。適切なイベントを使用して、この機能を提供する必要があります。
データ バインディングの詳細については、「ASP.NET でのデータ アクセス」を参照してください。
![]() |
---|
このコントロールは、ユーザー入力を表示するために使用できます。ユーザー入力には悪意のあるクライアント スクリプトが含まれている可能性があります。アプリケーションに表示する前に、クライアントから送信された実行スクリプト、SQL ステートメントなどのコードの情報はすべて検査してください。できる限り、値は、このコントロールに表示する前に HTML エンコードするようにしてください。ASP.NET には入力要求の検証機能があり、ユーザー入力の中のスクリプトと HTML をブロックできます。検証サーバー コントロールは、ユーザー入力を査定する目的でも用意されています。詳細については、「検証コントロールの概要」を参照してください。 |
データ操作
FormView コントロールには、ユーザーがそのコントロール内の項目を使用して更新、削除、挿入、ページングを実行できる多数の組み込み機能が用意されています。FormView コントロールがデータ ソース コントロールにバインドされている場合、FormView コントロールは、データ ソース コントロールの機能を利用して、自動的な更新、削除、挿入、およびページングの各機能を提供します。
![]() |
---|
他の種類のデータ ソースでも、FormView コントロールは更新、削除、挿入、およびページングの各操作をサポートできますが、これらの操作の実装で、適切なイベント ハンドラを用意する必要があります。 |
FormView コントロールではテンプレートを使用するため、更新、削除、または挿入の各操作を実行するためのコマンド ボタンを自動的に生成する手段は用意されていません。これらのコマンド ボタンは、該当するテンプレートに手動で挿入する必要があります。FormView コントロールは、CommandName プロパティが特定の値に設定されているボタンを認識します。FormView コントロールが認識するコマンド ボタンの一覧を次の表に示します。
Commandname 値 | ||
---|---|---|
"Cancel" | 操作をキャンセルし、ユーザーが入力した値を破棄する更新操作または挿入操作で使用します。FormView コントロールは、その後、DefaultMode プロパティで指定されたモードに戻ります。 | |
"Delete" | 表示されているレコードをデータ ソースから削除する削除操作で使用します。ItemDeleting イベントおよび ItemDeleted イベントを発生させます。 | |
"Edit" | FormView コントロールを編集モードにする更新操作で使用します。EditItemTemplate プロパティで指定されたコンテンツがデータ行に表示されます。 | |
"Insert" | ユーザーが入力した値を使用してデータ ソースに新規レコードを挿入する挿入操作で使用します。ItemInserting イベントおよび ItemInserted イベントを発生させます。 | |
"New" | FormView コントロールを挿入モードにする挿入操作で使用します。InsertItemTemplate プロパティで指定されたコンテンツがデータ行に表示されます。 | |
"Page" | ページングを実行するページ行のボタンを表すページング操作で使用します。ページング操作を指定するには、ボタンの CommandArgument プロパティを "Next"、"Prev"、"First"、"Last"、または移動先のページのインデックスに設定します。PageIndexChanging イベントおよび PageIndexChanged イベントを発生させます。 | |
"Update" | ユーザーが入力した値を使用して、データ ソース内の表示されているレコードを更新する更新操作で使用します。ItemUpdating イベントおよび ItemUpdated イベントを発生させます。 |
(表示されているレコードをすぐに削除する) Delete ボタンとは異なり、Edit ボタンまたは New ボタンをクリックすると、FormView コントロールが編集モード (Edit ボタンの場合) または挿入モード (New ボタンの場合) になります。編集モードでは、EditItemTemplate プロパティに格納されているコンテンツが現在のデータ項目に表示されます。一般的に、項目編集テンプレートは、Edit ボタンが Update ボタンと Cancel ボタンに置き換えられるように定義されます。通常は、フィールドのデータ型に適した入力コントロール (TextBox コントロールや CheckBox コントロールなど) も、ユーザーが変更するフィールドの値を設定した状態で表示されます。Update ボタンをクリックすると、データ ソースのレコードが更新され、Cancel ボタンをクリックすると、すべての変更が放棄されます。
同様に、コントロールが挿入モードの場合は、InsertItemTemplate プロパティに格納されているコンテンツがデータ項目用に表示されます。一般的に、項目挿入テンプレートは、New ボタンが Insert ボタンと Cancel ボタンに置き換えられるように定義され、新規レコードの値を入力するために空の入力コントロールがユーザーに表示されます。Insert ボタンをクリックするとデータ ソースにレコードが挿入され、Cancel ボタンをクリックするとすべての変更が放棄されます。
FormView コントロールには、ユーザーがデータ ソース内の他のレコードに移動できるページング機能が用意されています。この機能が有効になっている場合、ページ ナビゲーション コントロールを含む FormView コントロールにページ行が表示されます。ページングを有効にするには、AllowPaging プロパティを true に設定します。ページ行は、PagerStyle プロパティと PagerSettings プロパティに格納されているオブジェクトのプロパティを設定することによってカスタマイズできます。組み込みのページ行 UI を使用する代わりに、PagerTemplate プロパティを使用して、独自の UI を作成できます。
ユーザー インターフェイスのカスタマイズ
コントロールのさまざまな部分にスタイル プロパティを設定することによって、FormView コントロールの外観をカスタマイズできます。さまざまなスタイル プロパティの一覧を次の表に示します。
イベント
FormView コントロールには、プログラムに利用できる複数のイベントが用意されています。これにより、イベントが発生するたびにカスタム ルーチンが実行されるようにできます。FormView コントロールでサポートされるイベントの一覧を次の表に示します。
ユーザー補助
このコントロールに既定でレンダリングされるマークアップは、Web Content Accessibility Guidelines (WCAG) 1.0 の優先度 1 ガイドラインなどのユーザー補助に関する標準に適合しない可能性があります。このコントロールのユーザー補助サポートの詳細については、「ASP.NET コントロールとユーザー補助」を参照してください。

FormView コントロールを使用して、SqlDataSource コントロールから値を表示する方法を次の例に示します。
<%@ Page language="VB" %> <html> <body> <form runat="server"> <h3>FormView Example</h3> <asp:formview id="EmployeeFormView" datasourceid="EmployeeSource" allowpaging="true" datakeynames="EmployeeID" runat="server"> <itemtemplate> <table> <tr> <td> <asp:image id="EmployeeImage" imageurl='<%# Eval("PhotoPath") %>' alternatetext='<%# Eval("LastName") %>' runat="server"/> </td> <td> <h3><%# Eval("FirstName") %> <%# Eval("LastName") %></h3> <%# Eval("Title") %> </td> </tr> </table> </itemtemplate> <pagersettings position="Bottom" mode="NextPrevious"/> </asp:formview> <!-- This example uses Microsoft SQL Server and connects --> <!-- to the Northwind sample database. Use an ASP.NET --> <!-- expression to retrieve the connection string value --> <!-- from the Web.config file. --> <asp:sqldatasource id="EmployeeSource" selectcommand="Select [EmployeeID], [LastName], [FirstName], [Title], [PhotoPath] From [Employees]" connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" runat="server"/> </form> </body> </html>
<%@ Page language="C#" %> <html> <body> <form runat="server"> <h3>FormView Example</h3> <asp:formview id="EmployeeFormView" datasourceid="EmployeeSource" allowpaging="true" datakeynames="EmployeeID" runat="server"> <itemtemplate> <table> <tr> <td> <asp:image id="EmployeeImage" imageurl='<%# Eval("PhotoPath") %>' alternatetext='<%# Eval("LastName") %>' runat="server"/> </td> <td> <h3><%# Eval("FirstName") %> <%# Eval("LastName") %></h3> <%# Eval("Title") %> </td> </tr> </table> </itemtemplate> <pagersettings position="Bottom" mode="NextPrevious"/> </asp:formview> <!-- This example uses Microsoft SQL Server and connects --> <!-- to the Northwind sample database. Use an ASP.NET --> <!-- expression to retrieve the connection string value --> <!-- from the Web.config file. --> <asp:sqldatasource id="EmployeeSource" selectcommand="Select [EmployeeID], [LastName], [FirstName], [Title], [PhotoPath] From [Employees]" connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" runat="server"/> </form> </body> </html>
FormView コントロールを使用して既存のレコードを編集する方法を次の例に示します。
<%@ Page language="VB" %> <script runat="server"> Sub EmployeeFormView_ItemUpdating(ByVal sender As Object, ByVal e As FormViewUpdateEventArgs) Handles EmployeeFormView.ItemUpdating ' Validate the field values entered by the user. This ' example determines whether the user left any fields ' empty. Use the NewValues property to access the new ' values entered by the user. Dim emptyFieldList As ArrayList = ValidateFields(e.NewValues) If emptyFieldList.Count > 0 Then ' The user left some fields empty. Display an error message. ' Use the Keys property to retrieve the key field value. Dim keyValue As String = e.Keys("EmployeeID").ToString() MessageLabel.Text = "You must enter a value for each field of record " & _ keyValue & ".<br/>The following fields are missing:<br/><br/>" ' Display the missing fields. Dim value As String For Each value In emptyFieldList ' Use the OldValues property to access the original value ' of a field. MessageLabel.Text &= value & " - Original Value = " & _ e.OldValues(value).ToString() & "<br>" Next ' Cancel the update operation. e.Cancel = True Else ' The field values passed validation. Clear the ' error message label. MessageLabel.Text = "" End If End Sub Function ValidateFields(ByVal list As IOrderedDictionary) As ArrayList ' Create an ArrayList object to store the ' names of any empty fields. Dim emptyFieldList As New ArrayList() ' Iterate though the field values entered by ' the user and check for an empty field. Empty ' fields contain a null value. Dim entry As DictionaryEntry For Each entry In list If entry.Value Is String.Empty Then ' Add the field name to the ArrayList object. emptyFieldList.Add(entry.Key.ToString()) End If Next Return emptyFieldList End Function Sub EmployeeFormView_ModeChanging(ByVal sender As Object, ByVal e As FormViewModeEventArgs) Handles EmployeeFormView.ModeChanging If e.CancelingEdit Then ' The user canceled the update operation. ' Clear the error message label. MessageLabel.Text = "" End If End Sub </script> <html> <body> <form runat="server"> <h3>FormView Example</h3> <asp:formview id="EmployeeFormView" datasourceid="EmployeeSource" allowpaging="true" datakeynames="EmployeeID" headertext="Employee Record" emptydatatext="No employees found." runat="server"> <headerstyle backcolor="CornFlowerBlue" forecolor="White" font-size="14" horizontalalign="Center" wrap="false"/> <rowstyle backcolor="LightBlue" wrap="false"/> <pagerstyle backcolor="CornFlowerBlue"/> <itemtemplate> <table> <tr> <td rowspan="6"> <asp:image id="EmployeeImage" imageurl='<%# Eval("PhotoPath") %>' alternatetext='<%# Eval("LastName") %>' runat="server"/> </td> <td colspan="2"> </td> </tr> <tr> <td> <b>Name:</b> </td> <td> <%# Eval("FirstName") %> <%# Eval("LastName") %> </td> </tr> <tr> <td> <b>Title:</b> </td> <td> <%# Eval("Title") %> </td> </tr> <tr> <td> <b>Hire Date:</b> </td> <td> <%# Eval("HireDate","{0:d}") %> </td> </tr> <tr height="150" valign="top"> <td> <b>Address:</b> </td> <td> <%# Eval("Address") %><br/> <%# Eval("City") %> <%# Eval("Region") %> <%# Eval("PostalCode") %><br/> <%# Eval("Country") %> </td> </tr> <tr> <td colspan="2"> <asp:linkbutton id="Edit" text="Edit" commandname="Edit" runat="server"/> </td> </tr> </table> </itemtemplate> <edititemtemplate> <table> <tr> <td rowspan="6"> <asp:image id="EmployeeEditImage" imageurl='<%# Eval("PhotoPath") %>' alternatetext='<%# Eval("LastName") %>' runat="server"/> </td> <td colspan="2"> </td> </tr> <tr> <td> <b>Name:</b> </td> <td> <asp:textbox id="FirstNameUpdateTextBox" text='<%# Bind("FirstName") %>' runat="server"/> <asp:textbox id="LastNameUpdateTextBox" text='<%# Bind("LastName") %>' runat="server"/> </td> </tr> <tr> <td> <b>Title:</b> </td> <td> <asp:textbox id="TitleUpdateTextBox" text='<%# Bind("Title") %>' runat="server"/> </td> </tr> <tr> <td> <b>Hire Date:</b> </td> <td> <asp:textbox id="HireDateUpdateTextBox" text='<%# Bind("HireDate", "{0:d}") %>' runat="server"/> </td> </tr> <tr height="150" valign="top"> <td> <b>Address:</b> </td> <td> <asp:textbox id="AddressUpdateTextBox" text='<%# Bind("Address") %>' runat="server"/> <br/> <asp:textbox id="CityUpdateTextBox" text='<%# Bind("City") %>' runat="server"/> <asp:textbox id="RegionUpdateTextBox" text='<%# Bind("Region") %>' width="40" runat="server"/> <asp:textbox id="PostalCodeUpdateTextBox" text='<%# Bind("PostalCode") %>' width="60" runat="server"/> <br/> <asp:textbox id="CountryUpdateTextBox" text='<%# Bind("Country") %>' runat="server"/> </td> </tr> <tr> <td colspan="2"> <asp:linkbutton id="UpdateButton" text="Update" commandname="Update" runat="server"/> <asp:linkbutton id="CancelButton" text="Cancel" commandname="Cancel" runat="server"/> </td> </tr> </table> </edititemtemplate> <pagersettings position="Bottom" mode="Numeric"/> </asp:formview> <br/><br/> <asp:label id="MessageLabel" forecolor="Red" runat="server"/> <!-- This example uses Microsoft SQL Server and connects --> <!-- to the Northwind sample database. Use an ASP.NET --> <!-- expression to retrieve the connection string value --> <!-- from the Web.config file. --> <asp:sqldatasource id="EmployeeSource" selectcommand="Select [EmployeeID], [LastName], [FirstName], [Title], [Address], [City], [Region], [PostalCode], [Country], [HireDate], [PhotoPath] From [Employees]" updatecommand="Update [Employees] Set [LastName]=@LastName, [FirstName]=@FirstName, [Title]=@Title, [Address]=@Address, [City]=@City, [Region]=@Region, [PostalCode]=@PostalCode, [Country]=@Country Where [EmployeeID]=@EmployeeID" connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" runat="server"/> </form> </body> </html>
<%@ Page language="C#" %> <script runat="server"> void EmployeeFormView_ItemUpdating(Object sender, FormViewUpdateEventArgs e) { // Validate the field values entered by the user. This // example determines whether the user left any fields // empty. Use the NewValues property to access the new // values entered by the user. ArrayList emptyFieldList = ValidateFields(e.NewValues); if (emptyFieldList.Count > 0) { // The user left some fields empty. Display an error message. // Use the Keys property to retrieve the key field value. String keyValue = e.Keys["EmployeeID"].ToString(); MessageLabel.Text = "You must enter a value for each field of record " + keyValue + ".<br/>The following fields are missing:<br/><br/>"; // Display the missing fields. foreach (String value in emptyFieldList) { // Use the OldValues property to access the original value // of a field. MessageLabel.Text += value + " - Original Value = " + e.OldValues[value].ToString() + "<br>"; } // Cancel the update operation. e.Cancel = true; } else { // The field values passed validation. Clear the // error message label. MessageLabel.Text = ""; } } ArrayList ValidateFields(IOrderedDictionary list) { // Create an ArrayList object to store the // names of any empty fields. ArrayList emptyFieldList = new ArrayList(); // Iterate though the field values entered by // the user and check for an empty field. Empty // fields contain a null value. foreach (DictionaryEntry entry in list) { if (entry.Value == String.Empty) { // Add the field name to the ArrayList object. emptyFieldList.Add(entry.Key.ToString()); } } return emptyFieldList; } void EmployeeFormView_ModeChanging(Object sender, FormViewModeEventArgs e) { if (e.CancelingEdit) { // The user canceled the update operation. // Clear the error message label. MessageLabel.Text = ""; } } </script> <html> <body> <form runat="server"> <h3>FormView Example</h3> <asp:formview id="EmployeeFormView" datasourceid="EmployeeSource" allowpaging="true" datakeynames="EmployeeID" headertext="Employee Record" emptydatatext="No employees found." onitemupdating="EmployeeFormView_ItemUpdating" onmodechanging="EmployeeFormView_ModeChanging" runat="server"> <headerstyle backcolor="CornFlowerBlue" forecolor="White" font-size="14" horizontalalign="Center" wrap="false"/> <rowstyle backcolor="LightBlue" wrap="false"/> <pagerstyle backcolor="CornFlowerBlue"/> <itemtemplate> <table> <tr> <td rowspan="6"> <asp:image id="EmployeeImage" imageurl='<%# Eval("PhotoPath") %>' alternatetext='<%# Eval("LastName") %>' runat="server"/> </td> <td colspan="2"> </td> </tr> <tr> <td> <b>Name:</b> </td> <td> <%# Eval("FirstName") %> <%# Eval("LastName") %> </td> </tr> <tr> <td> <b>Title:</b> </td> <td> <%# Eval("Title") %> </td> </tr> <tr> <td> <b>Hire Date:</b> </td> <td> <%# Eval("HireDate","{0:d}") %> </td> </tr> <tr height="150" valign="top"> <td> <b>Address:</b> </td> <td> <%# Eval("Address") %><br/> <%# Eval("City") %> <%# Eval("Region") %> <%# Eval("PostalCode") %><br/> <%# Eval("Country") %> </td> </tr> <tr> <td colspan="2"> <asp:linkbutton id="Edit" text="Edit" commandname="Edit" runat="server"/> </td> </tr> </table> </itemtemplate> <edititemtemplate> <table> <tr> <td rowspan="6"> <asp:image id="EmployeeEditImage" imageurl='<%# Eval("PhotoPath") %>' alternatetext='<%# Eval("LastName") %>' runat="server"/> </td> <td colspan="2"> </td> </tr> <tr> <td> <b>Name:</b> </td> <td> <asp:textbox id="FirstNameUpdateTextBox" text='<%# Bind("FirstName") %>' runat="server"/> <asp:textbox id="LastNameUpdateTextBox" text='<%# Bind("LastName") %>' runat="server"/> </td> </tr> <tr> <td> <b>Title:</b> </td> <td> <asp:textbox id="TitleUpdateTextBox" text='<%# Bind("Title") %>' runat="server"/> </td> </tr> <tr> <td> <b>Hire Date:</b> </td> <td> <asp:textbox id="HireDateUpdateTextBox" text='<%# Bind("HireDate", "{0:d}") %>' runat="server"/> </td> </tr> <tr height="150" valign="top"> <td> <b>Address:</b> </td> <td> <asp:textbox id="AddressUpdateTextBox" text='<%# Bind("Address") %>' runat="server"/> <br/> <asp:textbox id="CityUpdateTextBox" text='<%# Bind("City") %>' runat="server"/> <asp:textbox id="RegionUpdateTextBox" text='<%# Bind("Region") %>' width="40" runat="server"/> <asp:textbox id="PostalCodeUpdateTextBox" text='<%# Bind("PostalCode") %>' width="60" runat="server"/> <br/> <asp:textbox id="CountryUpdateTextBox" text='<%# Bind("Country") %>' runat="server"/> </td> </tr> <tr> <td colspan="2"> <asp:linkbutton id="UpdateButton" text="Update" commandname="Update" runat="server"/> <asp:linkbutton id="CancelButton" text="Cancel" commandname="Cancel" runat="server"/> </td> </tr> </table> </edititemtemplate> <pagersettings position="Bottom" mode="Numeric"/> </asp:formview> <br/><br/> <asp:label id="MessageLabel" forecolor="Red" runat="server"/> <!-- This example uses Microsoft SQL Server and connects --> <!-- to the Northwind sample database. Use an ASP.NET --> <!-- expression to retrieve the connection string value --> <!-- from the Web.config file. --> <asp:sqldatasource id="EmployeeSource" selectcommand="Select [EmployeeID], [LastName], [FirstName], [Title], [Address], [City], [Region], [PostalCode], [Country], [HireDate], [PhotoPath] From [Employees]" updatecommand="Update [Employees] Set [LastName]=@LastName, [FirstName]=@FirstName, [Title]=@Title, [Address]=@Address, [City]=@City, [Region]=@Region, [PostalCode]=@PostalCode, [Country]=@Country Where [EmployeeID]=@EmployeeID" connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" runat="server"/> </form> </body> </html>
FormView コントロールを使用して新規レコードを挿入する方法を次の例に示します。
<%@ Page language="VB" %> <html> <body> <form runat="server"> <h3>FormView InsertItemTemplate Example</h3> <asp:formview id="EmployeeFormView" datasourceid="EmployeeSource" allowpaging="true" datakeynames="EmployeeID" emptydatatext="No employees found." runat="server"> <rowstyle backcolor="LightGreen" wrap="false"/> <insertrowstyle backcolor="LightBlue" wrap="false"/> <itemtemplate> <table> <tr> <td rowspan="5"> <asp:image id="CompanyLogoImage" imageurl="~/Images/Logo.jpg" alternatetext="Company Logo" runat="server"/> </td> <td colspan="2"> </td> </tr> <tr> <td> <b>Name:</b> </td> <td> <%# Eval("FirstName") %> <%# Eval("LastName") %> </td> </tr> <tr> <td> <b>Title:</b> </td> <td> <%# Eval("Title") %> </td> </tr> <tr> <td colspan="2"> <asp:linkbutton id="NewButton" text="New" commandname="New" runat="server"/> </td> </tr> </table> </itemtemplate> <insertitemtemplate> <table> <tr> <td rowspan="4"> <asp:image id="CompanyLogoEditImage" imageurl="~/Images/Logo.jpg" alternatetext="Company Logo" runat="server"/> </td> <td colspan="2"> </td> </tr> <tr> <td> <b>Name:</b> </td> <td> <asp:textbox id="FirstNameInsertTextBox" text='<%# Bind("FirstName") %>' runat="server"/> <asp:textbox id="LastNameInsertTextBox" text='<%# Bind("LastName") %>' runat="server"/> </td> </tr> <tr> <td> <b>Title:</b> </td> <td> <asp:textbox id="TitleInsertTextBox" text='<%# Bind("Title") %>' runat="server"/> </td> </tr> <tr> <td colspan="2"> <asp:linkbutton id="InsertButton" text="Insert" commandname="Insert" runat="server"/> <asp:linkbutton id="CancelButton" text="Cancel" commandname="Cancel" runat="server"/> </td> </tr> </table> </insertitemtemplate> </asp:formview> <!-- This example uses Microsoft SQL Server and connects --> <!-- to the Northwind sample database. Use an ASP.NET --> <!-- expression to retrieve the connection string value --> <!-- from the Web.config file. --> <asp:sqldatasource id="EmployeeSource" selectcommand="Select [EmployeeID], [LastName], [FirstName], [Title], [PhotoPath] From [Employees]" insertcommand="Insert Into [Employees] ([LastName], [FirstName], [Title]) VALUES (@LastName, @FirstName, @Title)" connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" runat="server"/> </form> </body> </html>
<%@ Page language="C#" %> <html> <body> <form runat="server"> <h3>FormView InsertItemTemplate Example</h3> <asp:formview id="EmployeeFormView" datasourceid="EmployeeSource" allowpaging="true" datakeynames="EmployeeID" emptydatatext="No employees found." runat="server"> <rowstyle backcolor="LightGreen" wrap="false"/> <insertrowstyle backcolor="LightBlue" wrap="false"/> <itemtemplate> <table> <tr> <td rowspan="5"> <asp:image id="CompanyLogoImage" imageurl="~/Images/Logo.jpg" alternatetext="Company Logo" runat="server"/> </td> <td colspan="2"> </td> </tr> <tr> <td> <b>Name:</b> </td> <td> <%# Eval("FirstName") %> <%# Eval("LastName") %> </td> </tr> <tr> <td> <b>Title:</b> </td> <td> <%# Eval("Title") %> </td> </tr> <tr> <td colspan="2"> <asp:linkbutton id="NewButton" text="New" commandname="New" runat="server"/> </td> </tr> </table> </itemtemplate> <insertitemtemplate> <table> <tr> <td rowspan="4"> <asp:image id="CompanyLogoEditImage" imageurl="~/Images/Logo.jpg" alternatetext="Company Logo" runat="server"/> </td> <td colspan="2"> </td> </tr> <tr> <td> <b>Name:</b> </td> <td> <asp:textbox id="FirstNameInsertTextBox" text='<%# Bind("FirstName") %>' runat="server"/> <asp:textbox id="LastNameInsertTextBox" text='<%# Bind("LastName") %>' runat="server"/> </td> </tr> <tr> <td> <b>Title:</b> </td> <td> <asp:textbox id="TitleInsertTextBox" text='<%# Bind("Title") %>' runat="server"/> </td> </tr> <tr> <td colspan="2"> <asp:linkbutton id="InsertButton" text="Insert" commandname="Insert" runat="server"/> <asp:linkbutton id="CancelButton" text="Cancel" commandname="Cancel" runat="server"/> </td> </tr> </table> </insertitemtemplate> </asp:formview> <!-- This example uses Microsoft SQL Server and connects --> <!-- to the Northwind sample database. Use an ASP.NET --> <!-- expression to retrieve the connection string value --> <!-- from the Web.config file. --> <asp:sqldatasource id="EmployeeSource" selectcommand="Select [EmployeeID], [LastName], [FirstName], [Title], [PhotoPath] From [Employees]" insertcommand="Insert Into [Employees] ([LastName], [FirstName], [Title]) VALUES (@LastName, @FirstName, @Title)" connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" runat="server"/> </form> </body> </html>


System.Web.UI.Control
System.Web.UI.WebControls.WebControl
System.Web.UI.WebControls.BaseDataBoundControl
System.Web.UI.WebControls.DataBoundControl
System.Web.UI.WebControls.CompositeDataBoundControl
System.Web.UI.WebControls.FormView


Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


FormView メンバ
System.Web.UI.WebControls 名前空間
DetailsView クラス
GridView
FormViewRow
FormViewMode
AccessDataSource クラス
SqlDataSource
ObjectDataSource
AllowPaging
CurrentMode
DataKeyNames
DefaultMode
PagerStyle
PagerSettings
EditRowStyle
EmptyDataRowStyle
FooterStyle
HeaderStyle
InsertRowStyle
PagerStyle
RowStyle
EditItemTemplate
EmptyDataTemplate
FooterTemplate
HeaderTemplate
InsertItemTemplate
ItemTemplate
PagerTemplate
ItemCreated
ItemCommand
ItemDeleted
ItemDeleting
ItemInserted
ItemInserting
ItemUpdated
ItemUpdating
ModeChanged
ModeChanging
PageIndexChanged
PageIndexChanging
FormView コンストラクタ
アセンブリ: System.Web (system.web.dll 内)


このコンストラクタを使用して、FormView クラスの新しいインスタンスを初期化します。FormView コントロールをページに動的に追加するには、新しい FormView オブジェクトを作成してそのプロパティを設定し、コンテナ コントロール (PlaceHolder など) の Control.Controls コレクションに追加します。

ページに FormView コントロールを動的に追加する方法を次の例に示します。
<%@ page language="VB" %> <%@ import namespace="System.Data"%> <script runat="server"> ' To dynamically create a template for a FormView control, ' you must create a custom template class to represent ' the template. This template class represents the item ' template for a FormView control. Private NotInheritable Class EmployeeTemplate Implements ITemplate ' When implementing the ITemplate interface, you must ' implement the InstantiateIn method. The FormView ' control calls this method to create the template's ' content. Sub InstantiateIn(ByVal container As Control) Implements ITemplate.InstantiateIn ' Create the child controls contained in the template. ' For this example, the item template displays the ' FirstName and LastName fields from the data source. ' To support data binding, create event handlers ' for the DataBinding event of each child child control. ' The event handler must bind the appropriate value ' to the control. Dim firstNameLabel As New Label() firstNameLabel.ID = "FirstNameLabel" AddHandler firstNameLabel.DataBinding, AddressOf FirstNameLabel_DataBinding Dim lineBreak As LiteralControl = New LiteralControl("<br/>") Dim lastNameLabel As New Label() lastNameLabel.ID = "LastNameLabel" AddHandler lastNameLabel.DataBinding, AddressOf LastNameLabel_DataBinding ' Add the controls to the Controls collection of the ' container control. container.Controls.Add(firstNameLabel) container.Controls.Add(lineBreak) container.Controls.Add(lastNameLabel) End Sub ' This event handler binds the value of the FirstName field ' to the FirstNameLabel Label control displayed in the template. Private Sub FirstNameLabel_DataBinding(ByVal sender As Object, ByVal e As EventArgs) ' Use the sender parameter to retrieve the Label control ' being bound to data. Dim firstNameLabelControl As Label = CType(sender, Label) ' Retrieve the value to bind to the Label control. First, ' use the NamingContainer property to retrieve the parent ' control of the Label control. In this example, the parent ' control is the FormView control. Dim formViewContainer As FormView = CType(firstNameLabelControl.NamingContainer, FormView) ' Get the data item bound to the FormView control. Dim rowView As DataRowView = CType(formViewContainer.DataItem, DataRowView) ' Use the data item to retrieve the value of the FirstName field ' Set the Text property of the Label control to this value. firstNameLabelControl.Text = rowView("FirstName").ToString() End Sub ' This event handler binds the value of the LastName field ' to the LastNameLabel Label control displayed in the template. Private Sub LastNameLabel_DataBinding(ByVal sender As Object, ByVal e As EventArgs) ' Use the sender parameter to retrieve the Label control ' being bound to data. Dim lastNameLabelControl As Label = CType(sender, Label) ' Retrieve the value to bind to the Label control. First, ' use the NamingContainer property to retrieve the parent ' control of the Label control. In this example, the parent ' control is the FormView control. Dim formViewContainer As FormView = CType(lastNameLabelControl.NamingContainer, FormView) ' Get the data item bound to the FormView control. Dim rowView As DataRowView = CType(formViewContainer.DataItem, DataRowView) ' Use the data item to retrieve the value of the LastName field ' Set the Text property of the Label control to this value. lastNameLabelControl.Text = rowView("LastName").ToString() End Sub End Class Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) ' Create a new FormView object. Dim employeesFormView As New FormView() ' Set the FormView object's properties. employeesFormView.ID = "EmployeesFormView" employeesFormView.DataSourceID = "EmployeeSource" employeesFormView.AllowPaging = True employeesFormView.PagerSettings.Mode = PagerButtons.NextPrevious employeesFormView.HeaderText = "Employee Name" employeesFormView.RowStyle.BackColor = System.Drawing.Color.LightBlue employeesFormView.HeaderStyle.BackColor = System.Drawing.Color.Silver employeesFormView.PagerStyle.BackColor = System.Drawing.Color.Silver ' Create the dynamic template using the custom template class. employeesFormView.ItemTemplate = New EmployeeTemplate() ' Add the FormView object to the Controls collection ' of the PlaceHolder control. DetailsViewPlaceHolder.Controls.Add(employeesFormView) End Sub </script> <html> <body> <form runat="server"> <h3>FormView Constructor Example</h3> <!-- Use a PlaceHolder control as the container for the --> <!-- dynamically generated FormView control. --> <asp:PlaceHolder id="DetailsViewPlaceHolder" runat="server"/> <!-- This example uses Microsoft SQL Server and connects --> <!-- to the Northwind sample database. Use an ASP.NET --> <!-- expression to retrieve the connection string value --> <!-- from the Web.config file. --> <asp:sqldatasource id="EmployeeSource" selectcommand="Select [EmployeeID], [LastName], [FirstName] From [Employees]" connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" runat="server"/> </form> </body> </html>
<%@ page language="C#" %> <%@ import namespace="System.Data"%> <script runat="server"> // To dynamically create a template for a FormView control, // you must create a custom template class to represent // the template. This template class represents the item // template for a FormView control. private sealed class EmployeeTemplate : ITemplate { // When implementing the ITemplate interface, you must // implement the InstantiateIn method. The FormView // control calls this method to create the template's // content. void ITemplate.InstantiateIn(Control container) { // Create the child controls contained in the template. // For this example, the item template displays the // FirstName and LastName fields from the data source. // To support data binding, create event handlers // for the DataBinding event of each child child control. // The event handler must bind the appropriate value // to the control. Label firstNameLabel = new Label(); firstNameLabel.ID = "FirstNameLabel"; firstNameLabel.DataBinding += new EventHandler(FirstNameLabel_DataBinding); LiteralControl lineBreak = new LiteralControl("<br/>"); Label lastNameLabel = new Label(); lastNameLabel.ID = "LastNameLabel"; lastNameLabel.DataBinding += new EventHandler(LastNameLabel_DataBinding); // Add the controls to the Controls collection of the // container control. container.Controls.Add(firstNameLabel); container.Controls.Add(lineBreak); container.Controls.Add(lastNameLabel); } // This event handler binds the value of the FirstName field // to the FirstNameLabel Label control displayed in the template. private void FirstNameLabel_DataBinding(Object sender, EventArgs e) { // Use the sender parameter to retrieve the Label control // being bound to data. Label firstNameLabelControl = (Label)sender; // Retrieve the value to bind to the Label control. First, // use the NamingContainer property to retrieve the parent // control of the Label control. In this example, the parent // control is the FormView control. FormView formViewContainer = (FormView)firstNameLabelControl.NamingContainer; // Get the data item bound to the FormView control. DataRowView rowView = (DataRowView)formViewContainer.DataItem; // Use the data item to retrieve the value of the FirstName field // Set the Text property of the Label control to this value. firstNameLabelControl.Text = rowView["FirstName"].ToString(); } // This event handler binds the value of the LastName field // to the LastNameLabel Label control displayed in the template. private void LastNameLabel_DataBinding(Object sender, EventArgs e) { // Use the sender parameter to retrieve the Label control // being bound to data. Label lastNameLabelControl = (Label)sender; // Retrieve the value to bind to the Label control. First, // use the NamingContainer property to retrieve the parent // control of the Label control. In this example, the parent // control is the FormView control. FormView formViewContainer = (FormView)lastNameLabelControl.NamingContainer; // Get the data item bound to the FormView control. DataRowView rowView = (DataRowView)formViewContainer.DataItem; // Use the data item to retrieve the value of the LastName field. // Set the Text property of the Label control to this value. lastNameLabelControl.Text = rowView["LastName"].ToString(); } } void Page_Load(Object sender, EventArgs e) { // Create a new FormView object. FormView employeesFormView = new FormView(); // Set the FormView object's properties. employeesFormView.ID = "EmployeesFormView"; employeesFormView.DataSourceID = "EmployeeSource"; employeesFormView.AllowPaging = true; employeesFormView.PagerSettings.Mode = PagerButtons.NextPrevious; employeesFormView.HeaderText = "Employee Name"; employeesFormView.RowStyle.BackColor = System.Drawing.Color.LightBlue; employeesFormView.HeaderStyle.BackColor = System.Drawing.Color.Silver; employeesFormView.PagerStyle.BackColor = System.Drawing.Color.Silver; // Create the dynamic template using the custom template class. employeesFormView.ItemTemplate = new EmployeeTemplate(); // Add the FormView object to the Controls collection // of the PlaceHolder control. DetailsViewPlaceHolder.Controls.Add(employeesFormView); } </script> <html> <body> <form runat="server"> <h3>FormView Constructor Example</h3> <!-- Use a PlaceHolder control as the container for the --> <!-- dynamically generated FormView control. --> <asp:PlaceHolder id="DetailsViewPlaceHolder" runat="server"/> <!-- This example uses Microsoft SQL Server and connects --> <!-- to the Northwind sample database. Use an ASP.NET --> <!-- expression to retrieve the connection string value --> <!-- from the Web.config file. --> <asp:sqldatasource id="EmployeeSource" selectcommand="Select [EmployeeID], [LastName], [FirstName] From [Employees]" connectionstring="<%$ ConnectionStrings:NorthWindConnectionString%>" runat="server"/> </form> </body> </html>

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


FormView プロパティ



名前 | 説明 | |
---|---|---|
![]() | System.Web.UI.IDataItemContainer.DataItemIndex | このメンバの説明については、「IDataItemContainer.DataItemIndex」を参照してください。 |
![]() | System.Web.UI.IDataItemContainer.DisplayIndex | このメンバの説明については、「IDataItemContainer.DisplayIndex」を参照してください。 |

関連項目
FormView クラスSystem.Web.UI.WebControls 名前空間
DetailsView クラス
GridView
FormViewRow
FormViewMode
AccessDataSource クラス
SqlDataSource
ObjectDataSource
AllowPaging
CurrentMode
DataKeyNames
DefaultMode
PagerStyle
PagerSettings
EditRowStyle
EmptyDataRowStyle
FooterStyle
HeaderStyle
InsertRowStyle
PagerStyle
RowStyle
EditItemTemplate
EmptyDataTemplate
FooterTemplate
HeaderTemplate
InsertItemTemplate
ItemTemplate
PagerTemplate
ItemCreated
ItemCommand
ItemDeleted
ItemDeleting
ItemInserted
ItemInserting
ItemUpdated
ItemUpdating
ModeChanged
ModeChanging
PageIndexChanged
PageIndexChanging
FormView メソッド


名前 | 説明 | |
---|---|---|
![]() | AddAttributesToRender | 指定した HtmlTextWriterTag に表示する必要のある HTML 属性およびスタイルを追加します。このメソッドは、主にコントロールの開発者によって使用されます。 ( WebControl から継承されます。) |
![]() | AddedControl | 子コントロールが Control オブジェクトの Controls コレクションに追加された後に呼び出されます。 ( Control から継承されます。) |
![]() | AddParsedSubObject | サーバー コントロールに、XML または HTML の要素が解析されたことを通知し、その要素をサーバー コントロールの ControlCollection オブジェクトに追加します。 ( Control から継承されます。) |
![]() | BuildProfileTree | ページのトレースが有効な場合、サーバー コントロールに関する情報を収集し、これを表示するために Trace プロパティに渡します。 ( Control から継承されます。) |
![]() | ClearChildControlState | サーバー コントロールのすべての子コントロールについて、コントロールの状態情報を削除します。 ( Control から継承されます。) |
![]() | ClearChildState | サーバー コントロールのすべての子コントロールのビューステート情報およびコントロールの状態情報を削除します。 ( Control から継承されます。) |
![]() | ClearChildViewState | サーバー コントロールのすべての子コントロールのビューステート情報を削除します。 ( Control から継承されます。) |
![]() | ConfirmInitState | データ バインド コントロールの初期化状態を設定します。 ( BaseDataBoundControl から継承されます。) |
![]() | CreateChildControls | オーバーロードされます。 FormView コントロールの表示に使用するコントロール階層を作成します。 |
![]() | CreateControlCollection | サーバー コントロールの子コントロール (リテラルおよびサーバーの両方) を保持する新しい ControlCollection オブジェクトを作成します。 ( Control から継承されます。) |
![]() | CreateControlStyle | オーバーライドされます。 FormView コントロールの既定のテーブル スタイル オブジェクトを作成します。 |
![]() | CreateDataSourceSelectArguments | オーバーライドされます。 処理のためにデータ ソースに渡される引数を格納する DataSourceSelectArguments オブジェクトを作成します。 |
![]() | CreateRow | 指定した項目のインデックス、行の種類、および行の状態を使用して、FormViewRow オブジェクトを作成します。 |
![]() | CreateTable | FormView コントロールのコンテナ テーブルを作成します。 |
![]() | DataBind | オーバーロードされます。 呼び出されたサーバー コントロールと、そのすべての子コントロールにデータ ソースを連結します。 ( Control から継承されます。) |
![]() | DataBindChildren | データ ソースをサーバー コントロールの子コントロールにバインドします。 ( Control から継承されます。) |
![]() | EnsureChildControls | サーバー コントロールに子コントロールが含まれているかどうかを確認します。含まれていない場合、子コントロールを作成します。 ( Control から継承されます。) |
![]() | EnsureDataBound | オーバーライドされます。 必要に応じて FormView コントロールがデータにバインドされていることを確認します。 |
![]() | EnsureID | ID が割り当てられていないコントロールの ID を作成します。 ( Control から継承されます。) |
![]() | ExtractRowValues | データ行内で宣言された各フィールドの値を取得し、それらを指定した IOrderedDictionary オブジェクトに格納します。 |
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | FindControl | オーバーロードされます。 指定したサーバー コントロールの現在の名前付けコンテナを検索します。 ( Control から継承されます。) |
![]() | GetData | データ操作を実行するために、データ バインド コントロールが使用する DataSourceView オブジェクトを取得します。 ( DataBoundControl から継承されます。) |
![]() | GetDataSource | データ バインド コントロールが関連付けられている IDataSource インターフェイスを取得します (存在する場合)。 ( DataBoundControl から継承されます。) |
![]() | GetDesignModeState | コントロールのデザイン時データを取得します。 ( Control から継承されます。) |
![]() | HasEvents | コントロールまたは子コントロールに対してイベントが登録されているかどうかを示す値を返します。 ( Control から継承されます。) |
![]() | InitializePager | FormView コントロールのページ行を作成します。 |
![]() | InitializeRow | 指定した DetailsViewRow オブジェクトを初期化します。 |
![]() | IsLiteralContent | サーバー コントロールがリテラルな内容だけを保持しているかどうかを決定します。 ( Control から継承されます。) |
![]() | LoadControlState | オーバーライドされます。 EnableViewState プロパティが false に設定されていても、永続化する必要がある FormView コントロールのプロパティの状態を読み込みます。 |
![]() | LoadViewState | オーバーライドされます。 以前に保存した FormView コントロールのビューステートを読み込みます。 |
![]() | MapPathSecure | 仮想パス (絶対パスまたは相対パス) の割り当て先の物理パスを取得します。 ( Control から継承されます。) |
![]() | MarkAsDataBound | ビューステートのコントロールの状態を、データに正常にバインドされた状態に設定します。 ( DataBoundControl から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |
![]() | OnBubbleEvent | オーバーライドされます。 コントロールの下位階層から渡されたイベントを処理します。 |
![]() | OnDataBinding | DataBinding イベントを発生させます。 ( Control から継承されます。) |
![]() | OnDataBound | DataBound イベントを発生させます。 ( BaseDataBoundControl から継承されます。) |
![]() | OnDataPropertyChanged | 基本データ ソース識別プロパティのいずれかが変更された後、データ バインド コントロールをデータにバインドし直します。 ( DataBoundControl から継承されます。) |
![]() | OnDataSourceViewChanged | DataSourceViewChanged イベントを発生させます。 ( DataBoundControl から継承されます。) |
![]() | OnInit | オーバーライドされます。 Init イベントを発生させます。 |
![]() | OnItemCommand | ItemCommand イベントを発生させます。 |
![]() | OnItemCreated | ItemCreated イベントを発生させます。 |
![]() | OnItemDeleted | ItemDeleted イベントを発生させます。 |
![]() | OnItemDeleting | ItemDeleting イベントを発生させます。 |
![]() | OnItemInserted | ItemInserted イベントを発生させます。 |
![]() | OnItemInserting | ItemInserting イベントを発生させます。 |
![]() | OnItemUpdated | ItemUpdated イベントを発生させます。 |
![]() | OnItemUpdating | ItemUpdating イベントを発生させます。 |
![]() | OnLoad | Control.Load イベントを処理します。 ( DataBoundControl から継承されます。) |
![]() | OnModeChanged | ModeChanged イベントを発生させます。 |
![]() | OnModeChanging | ModeChanging イベントを発生させます。 |
![]() | OnPageIndexChanged | PageIndexChanged イベントを発生させます。 |
![]() | OnPageIndexChanging | PageIndexChanging イベントを発生させます。 |
![]() | OnPagePreLoad | コントロールが読み込まれる前に、データ バインド コントロールの初期化状態を設定します。 ( DataBoundControl から継承されます。) |
![]() | OnPreRender | PreRender イベントを処理します。 ( BaseDataBoundControl から継承されます。) |
![]() | OnUnload | Unload イベントを発生させます。 ( Control から継承されます。) |
![]() | OpenFile | ファイルの読み込みで使用される Stream を取得します。 ( Control から継承されます。) |
![]() | PerformDataBinding | オーバーライドされます。 指定したデータ ソースを FormView コントロールにバインドします。 |
![]() | PerformSelect | 関連するデータ ソースからデータを取得します。 ( DataBoundControl から継承されます。) |
![]() | PrepareControlHierarchy | FormView コントロールのコントロール階層を設定します。 |
![]() | RaiseBubbleEvent | イベントのソースおよびその情報をコントロールの親に割り当てます。 ( Control から継承されます。) |
![]() | RaisePostBackEvent | サーバーへのポストバック時に、FormView コントロールに適切なイベントを発生させます。 |
![]() | RemovedControl | 子コントロールが Control オブジェクトの Controls コレクションから削除された後に呼び出されます。 ( Control から継承されます。) |
![]() | Render | オーバーライドされます。 クライアントに FormView コントロールを表示します。 |
![]() | RenderChildren | クライアントに表示される内容の書き込みを行う、指定された HtmlTextWriter オブジェクトに、サーバー コントロールの子を出力します。 ( Control から継承されます。) |
![]() | RenderContents | コントロールの内容を指定したライタに出力します。このメソッドは、主にコントロールの開発者によって使用されます。 ( WebControl から継承されます。) |
![]() | RenderControl | オーバーロードされます。 サーバー コントロールの内容を出力し、トレースが有効である場合はコントロールに関するトレース情報を格納します。 ( Control から継承されます。) |
![]() | ResolveAdapter | 指定したコントロールを表示するコントロール アダプタを取得します。 ( Control から継承されます。) |
![]() | SaveControlState | オーバーライドされます。 Control.EnableViewState プロパティが false に設定されていても、永続化する必要がある FormView コントロールのプロパティの状態を保存します。 |
![]() | SaveViewState | オーバーライドされます。 FormView コントロールの現在のビューステートを保存します。 |
![]() | SetDesignModeState | コントロールのデザイン時データを設定します。 ( Control から継承されます。) |
![]() | TrackViewState | オーバーライドされます。 FormView コントロールに対するビューステートの変更の追跡と保存を始める開始点にマークを付けます。 |
![]() | ValidateDataSource | データ バインド コントロールのバインド先のオブジェクトが処理可能かどうかを確認します。 ( DataBoundControl から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | System.Web.UI.IPostBackEventHandler.RaisePostBackEvent | サーバーへのポストバック時に、FormView コントロールのイベントを発生させます。 |
![]() | System.Web.UI.WebControls.IPostBackContainer.GetPostBackOptions | FormView コントロールのポストバック イベントのオプションを確認します。 |

関連項目
FormView クラスSystem.Web.UI.WebControls 名前空間
DetailsView クラス
GridView
FormViewRow
FormViewMode
AccessDataSource クラス
SqlDataSource
ObjectDataSource
AllowPaging
CurrentMode
DataKeyNames
DefaultMode
PagerStyle
PagerSettings
EditRowStyle
EmptyDataRowStyle
FooterStyle
HeaderStyle
InsertRowStyle
PagerStyle
RowStyle
EditItemTemplate
EmptyDataTemplate
FooterTemplate
HeaderTemplate
InsertItemTemplate
ItemTemplate
PagerTemplate
ItemCreated
ItemCommand
ItemDeleted
ItemDeleting
ItemInserted
ItemInserting
ItemUpdated
ItemUpdating
ModeChanged
ModeChanging
PageIndexChanged
PageIndexChanging
FormView メンバ
ユーザー定義のテンプレートを使用して、データ ソースから単一レコードの値を表示します。FormView コントロールにより、レコードの編集、削除、および挿入ができます。
FormView データ型で公開されるメンバを以下の表に示します。





名前 | 説明 | |
---|---|---|
![]() | AddAttributesToRender | 指定した HtmlTextWriterTag に表示する必要のある HTML 属性およびスタイルを追加します。このメソッドは、主にコントロールの開発者によって使用されます。 (WebControl から継承されます。) |
![]() | AddedControl | 子コントロールが Control オブジェクトの Controls コレクションに追加された後に呼び出されます。 (Control から継承されます。) |
![]() | AddParsedSubObject | サーバー コントロールに、XML または HTML の要素が解析されたことを通知し、その要素をサーバー コントロールの ControlCollection オブジェクトに追加します。 (Control から継承されます。) |
![]() | BuildProfileTree | ページのトレースが有効な場合、サーバー コントロールに関する情報を収集し、これを表示するために Trace プロパティに渡します。 (Control から継承されます。) |
![]() | ClearChildControlState | サーバー コントロールのすべての子コントロールについて、コントロールの状態情報を削除します。 (Control から継承されます。) |
![]() | ClearChildState | サーバー コントロールのすべての子コントロールのビューステート情報およびコントロールの状態情報を削除します。 (Control から継承されます。) |
![]() | ClearChildViewState | サーバー コントロールのすべての子コントロールのビューステート情報を削除します。 (Control から継承されます。) |
![]() | ConfirmInitState | データ バインド コントロールの初期化状態を設定します。 (BaseDataBoundControl から継承されます。) |
![]() | CreateChildControls | オーバーロードされます。 FormView コントロールの表示に使用するコントロール階層を作成します。 |
![]() | CreateControlCollection | サーバー コントロールの子コントロール (リテラルおよびサーバーの両方) を保持する新しい ControlCollection オブジェクトを作成します。 (Control から継承されます。) |
![]() | CreateControlStyle | オーバーライドされます。 FormView コントロールの既定のテーブル スタイル オブジェクトを作成します。 |
![]() | CreateDataSourceSelectArguments | オーバーライドされます。 処理のためにデータ ソースに渡される引数を格納する DataSourceSelectArguments オブジェクトを作成します。 |
![]() | CreateRow | 指定した項目のインデックス、行の種類、および行の状態を使用して、FormViewRow オブジェクトを作成します。 |
![]() | CreateTable | FormView コントロールのコンテナ テーブルを作成します。 |
![]() | DataBind | オーバーロードされます。 呼び出されたサーバー コントロールと、そのすべての子コントロールにデータ ソースを連結します。 (Control から継承されます。) |
![]() | DataBindChildren | データ ソースをサーバー コントロールの子コントロールにバインドします。 (Control から継承されます。) |
![]() | EnsureChildControls | サーバー コントロールに子コントロールが含まれているかどうかを確認します。含まれていない場合、子コントロールを作成します。 (Control から継承されます。) |
![]() | EnsureDataBound | オーバーライドされます。 必要に応じて FormView コントロールがデータにバインドされていることを確認します。 |
![]() | EnsureID | ID が割り当てられていないコントロールの ID を作成します。 (Control から継承されます。) |
![]() | ExtractRowValues | データ行内で宣言された各フィールドの値を取得し、それらを指定した IOrderedDictionary オブジェクトに格納します。 |
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | FindControl | オーバーロードされます。 指定したサーバー コントロールの現在の名前付けコンテナを検索します。 (Control から継承されます。) |
![]() | GetData | データ操作を実行するために、データ バインド コントロールが使用する DataSourceView オブジェクトを取得します。 (DataBoundControl から継承されます。) |
![]() | GetDataSource | データ バインド コントロールが関連付けられている IDataSource インターフェイスを取得します (存在する場合)。 (DataBoundControl から継承されます。) |
![]() | GetDesignModeState | コントロールのデザイン時データを取得します。 (Control から継承されます。) |
![]() | HasEvents | コントロールまたは子コントロールに対してイベントが登録されているかどうかを示す値を返します。 (Control から継承されます。) |
![]() | InitializePager | FormView コントロールのページ行を作成します。 |
![]() | InitializeRow | 指定した DetailsViewRow オブジェクトを初期化します。 |
![]() | IsLiteralContent | サーバー コントロールがリテラルな内容だけを保持しているかどうかを決定します。 (Control から継承されます。) |
![]() | LoadControlState | オーバーライドされます。 EnableViewState プロパティが false に設定されていても、永続化する必要がある FormView コントロールのプロパティの状態を読み込みます。 |
![]() | LoadViewState | オーバーライドされます。 以前に保存した FormView コントロールのビューステートを読み込みます。 |
![]() | MapPathSecure | 仮想パス (絶対パスまたは相対パス) の割り当て先の物理パスを取得します。 (Control から継承されます。) |
![]() | MarkAsDataBound | ビューステートのコントロールの状態を、データに正常にバインドされた状態に設定します。 (DataBoundControl から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |
![]() | OnBubbleEvent | オーバーライドされます。 コントロールの下位階層から渡されたイベントを処理します。 |
![]() | OnDataBinding | DataBinding イベントを発生させます。 (Control から継承されます。) |
![]() | OnDataBound | DataBound イベントを発生させます。 (BaseDataBoundControl から継承されます。) |
![]() | OnDataPropertyChanged | 基本データ ソース識別プロパティのいずれかが変更された後、データ バインド コントロールをデータにバインドし直します。 (DataBoundControl から継承されます。) |
![]() | OnDataSourceViewChanged | DataSourceViewChanged イベントを発生させます。 (DataBoundControl から継承されます。) |
![]() | OnInit | オーバーライドされます。 Init イベントを発生させます。 |
![]() | OnItemCommand | ItemCommand イベントを発生させます。 |
![]() | OnItemCreated | ItemCreated イベントを発生させます。 |
![]() | OnItemDeleted | ItemDeleted イベントを発生させます。 |
![]() | OnItemDeleting | ItemDeleting イベントを発生させます。 |
![]() | OnItemInserted | ItemInserted イベントを発生させます。 |
![]() | OnItemInserting | ItemInserting イベントを発生させます。 |
![]() | OnItemUpdated | ItemUpdated イベントを発生させます。 |
![]() | OnItemUpdating | ItemUpdating イベントを発生させます。 |
![]() | OnLoad | Control.Load イベントを処理します。 (DataBoundControl から継承されます。) |
![]() | OnModeChanged | ModeChanged イベントを発生させます。 |
![]() | OnModeChanging | ModeChanging イベントを発生させます。 |
![]() | OnPageIndexChanged | PageIndexChanged イベントを発生させます。 |
![]() | OnPageIndexChanging | PageIndexChanging イベントを発生させます。 |
![]() | OnPagePreLoad | コントロールが読み込まれる前に、データ バインド コントロールの初期化状態を設定します。 (DataBoundControl から継承されます。) |
![]() | OnPreRender | PreRender イベントを処理します。 (BaseDataBoundControl から継承されます。) |
![]() | OnUnload | Unload イベントを発生させます。 (Control から継承されます。) |
![]() | OpenFile | ファイルの読み込みで使用される Stream を取得します。 (Control から継承されます。) |
![]() | PerformDataBinding | オーバーライドされます。 指定したデータ ソースを FormView コントロールにバインドします。 |
![]() | PerformSelect | 関連するデータ ソースからデータを取得します。 (DataBoundControl から継承されます。) |
![]() | PrepareControlHierarchy | FormView コントロールのコントロール階層を設定します。 |
![]() | RaiseBubbleEvent | イベントのソースおよびその情報をコントロールの親に割り当てます。 (Control から継承されます。) |
![]() | RaisePostBackEvent | サーバーへのポストバック時に、FormView コントロールに適切なイベントを発生させます。 |
![]() | RemovedControl | 子コントロールが Control オブジェクトの Controls コレクションから削除された後に呼び出されます。 (Control から継承されます。) |
![]() | Render | オーバーライドされます。 クライアントに FormView コントロールを表示します。 |
![]() | RenderChildren | クライアントに表示される内容の書き込みを行う、指定された HtmlTextWriter オブジェクトに、サーバー コントロールの子を出力します。 (Control から継承されます。) |
![]() | RenderContents | コントロールの内容を指定したライタに出力します。このメソッドは、主にコントロールの開発者によって使用されます。 (WebControl から継承されます。) |
![]() | RenderControl | オーバーロードされます。 サーバー コントロールの内容を出力し、トレースが有効である場合はコントロールに関するトレース情報を格納します。 (Control から継承されます。) |
![]() | ResolveAdapter | 指定したコントロールを表示するコントロール アダプタを取得します。 (Control から継承されます。) |
![]() | SaveControlState | オーバーライドされます。 Control.EnableViewState プロパティが false に設定されていても、永続化する必要がある FormView コントロールのプロパティの状態を保存します。 |
![]() | SaveViewState | オーバーライドされます。 FormView コントロールの現在のビューステートを保存します。 |
![]() | SetDesignModeState | コントロールのデザイン時データを設定します。 (Control から継承されます。) |
![]() | TrackViewState | オーバーライドされます。 FormView コントロールに対するビューステートの変更の追跡と保存を始める開始点にマークを付けます。 |
![]() | ValidateDataSource | データ バインド コントロールのバインド先のオブジェクトが処理可能かどうかを確認します。 (DataBoundControl から継承されます。) |


名前 | 説明 | |
---|---|---|
![]() | System.Web.UI.IPostBackEventHandler.RaisePostBackEvent | サーバーへのポストバック時に、FormView コントロールのイベントを発生させます。 |
![]() | System.Web.UI.WebControls.IPostBackContainer.GetPostBackOptions | FormView コントロールのポストバック イベントのオプションを確認します。 |
![]() | System.Web.UI.IDataItemContainer.DataItemIndex | このメンバの説明については、「IDataItemContainer.DataItemIndex」を参照してください。 |
![]() | System.Web.UI.IDataItemContainer.DisplayIndex | このメンバの説明については、「IDataItemContainer.DisplayIndex」を参照してください。 |

関連項目
FormView クラスSystem.Web.UI.WebControls 名前空間
DetailsView クラス
GridView
FormViewRow
FormViewMode
AccessDataSource クラス
SqlDataSource
ObjectDataSource
AllowPaging
CurrentMode
DataKeyNames
DefaultMode
PagerStyle
PagerSettings
EditRowStyle
EmptyDataRowStyle
FooterStyle
HeaderStyle
InsertRowStyle
PagerStyle
RowStyle
EditItemTemplate
EmptyDataTemplate
FooterTemplate
HeaderTemplate
InsertItemTemplate
ItemTemplate
PagerTemplate
ItemCreated
ItemCommand
ItemDeleted
ItemDeleting
ItemInserted
ItemInserting
ItemUpdated
ItemUpdating
ModeChanged
ModeChanging
PageIndexChanged
PageIndexChanging
- FormViewのページへのリンク