FormView.Row プロパティ
アセンブリ: System.Web (system.web.dll 内)


プログラムによって、データ行を表す FormViewRow オブジェクトにアクセスするには、Row プロパティを使用します。データ行には、(CurrentMode プロパティで指定された) 現在のモード用に表示されるテンプレートに基づいて、異なるコンテンツが含まれます。現在のモードのテンプレートのコンテンツにのみアクセスできます。各モードで使用されるテンプレートを次の表に示します。
このプロパティは通常、プログラムによってデータ行を操作する必要がある場合 (カスタム コンテンツを追加する場合など) に使用されます。Row プロパティへの変更は、FormView コントロールがデータにバインドされた後に実行する必要があります。そうしないと、FormView コントロールによって変更が上書きされます。

Row プロパティを使用して、ItemCreated イベント中にデータ行のプロパティにアクセスする方法を次の例に示します。
<%@ page language="VB" %> <%@ import namespace="System.Data" %> <script runat="server"> Sub EmployeeFormView_ItemCreated(ByVal sender As Object, ByVal e As EventArgs) ' Use the Row property to retrieve the data row from ' the FormView control. Dim row As FormViewRow = EmployeeFormView.Row ' Get the data item bound to the FormView control. Dim rowView As DataRowView = CType(EmployeeFormView.DataItem, DataRowView) ' Set the ToolTip property of the data row. row.ToolTip = rowView("FirstName").ToString() & " " & _ rowView("LastName").ToString() End Sub </script> <html> <body> <form runat="server"> <h3>FormView Row Example</h3> <asp:formview id="EmployeeFormView" datasourceid="EmployeeSource" allowpaging="true" datakeynames="EmployeeID" onitemcreated="EmployeeFormView_ItemCreated" 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> </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#" %> <%@ import namespace="System.Data" %> <script runat="server"> void EmployeeFormView_ItemCreated(Object sender, EventArgs e) { // Use the Row property to retrieve the data row from // the FormView control. FormViewRow row = EmployeeFormView.Row; // Get the data item bound to the FormView control. DataRowView rowView = (DataRowView)EmployeeFormView.DataItem; // Set the ToolTip property of the data row. row.ToolTip = rowView["FirstName"].ToString() + " " + rowView["LastName"].ToString(); } </script> <html> <body> <form runat="server"> <h3>FormView Row Example</h3> <asp:formview id="EmployeeFormView" datasourceid="EmployeeSource" allowpaging="true" datakeynames="EmployeeID" onitemcreated="EmployeeFormView_ItemCreated" 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> </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>

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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


FormViewRow イベント

名前 | 説明 | |
---|---|---|
![]() | DataBinding | サーバー コントロールがデータ ソースに連結すると発生します。 ( Control から継承されます。) |
![]() | Disposed | サーバー コントロールがメモリから解放されると発生します。これは、ASP.NET ページが要求されている場合のサーバー コントロールの有効期間における最終段階です。 ( Control から継承されます。) |
![]() | Init | サーバー コントロールが初期化されると発生します。これは、サーバー コントロールの有効期間における最初の手順です。 ( Control から継承されます。) |
![]() | Load | サーバー コントロールが Page オブジェクトに読み込まれると発生します。 ( Control から継承されます。) |
![]() | PreRender | Control オブジェクトの読み込み後、表示を開始する前に発生します。 ( Control から継承されます。) |
![]() | Unload | サーバー コントロールがメモリからアンロードされると発生します。 ( Control から継承されます。) |

関連項目
FormViewRow クラスSystem.Web.UI.WebControls 名前空間
FormView クラス
FormView.BottomPagerRow プロパティ
FormView.FooterRow プロパティ
FormView.HeaderRow プロパティ
FormView.Row プロパティ
FormView.TopPagerRow プロパティ
DataBoundLiteralControl
TableCell
Controls
FindControl
TableRow
Cells
FormViewRow.ItemIndex プロパティ
FormViewRow.RowState プロパティ
FormViewRow.RowType プロパティ
FormViewRow クラス
アセンブリ: System.Web (system.web.dll 内)


FormViewRow クラスは、FormView コントロールの個別の行を表すために使用されます。FormView コントロールの各行には、行の種類が指定されています。さまざまな行の種類の一覧を次の表に示します。
行の種類 | |
---|---|
DataControlRowType.DataRow | |
DataControlRowType.EmptyDataRow | FormView コントロールの空のデータ行。空のデータ行は、表示するレコードがない場合に FormView コントロールに表示されます。 |
DataControlRowType.Footer | |
DataControlRowType.Header | |
DataControlRowType.Pager |
FormViewRow オブジェクトの行の種類を確認するには、RowType プロパティを使用します。FormViewRow オブジェクトには、状態も関連付けられます。状態は、次の表に示す値のビットごとの組み合わせになります。
状態の値 | |
---|---|
DataControlRowState.Edit | |
DataControlRowState.Insert | |
DataControlRowState.Normal | |
DataControlRowState.Selected |
FormViewRow オブジェクトの状態を確認するには、RowState プロパティを使用します。
FormView コントロールは、データ行に含まれるこのコントロールの ItemTemplate プロパティの内容を表示します。データ行にアクセスするには、Row プロパティを使用します。データ ソースの現在のデータ項目のインデックスを確認するには、ItemIndex プロパティを使用します。
Cells プロパティを使用して、FormViewRow オブジェクトの個別のセルにアクセスできます。セルにコントロールが格納されている場合は、次のいずれかの方法を使用して、セルからコントロールを取得できます。
FormViewRow クラスのインスタンスの初期プロパティ値の一覧については、FormViewRow コンストラクタのトピックを参照してください。

項目行を表す FormViewRow オブジェクトから Image コントロールを取得する方法を次の例に示します。Image コントロールは、編集テンプレートと項目テンプレートで宣言されています。
<%@ page language="VB" %> <%@ import namespace="System.Data" %> <script runat="server"> Sub EmployeeFormView_DataBound(ByVal sender As Object, ByVal e As EventArgs) ' Use the Row property to retrieve the data row from ' the FormView control. Dim row As FormViewRow = EmployeeFormView.Row ' Get the data item bound to the FormView control. Dim rowView As DataRowView = CType(EmployeeFormView.DataItem, DataRowView) ' Retrieve the Image control from the appropriate template ' based on the current mode. Dim employeePhoto As Image = Nothing Select Case EmployeeFormView.CurrentMode Case FormViewMode.ReadOnly employeePhoto = CType(row.FindControl("EmployeeImage"), Image) Case FormViewMode.Edit employeePhoto = CType(row.FindControl("EmployeeEditImage"), Image) Case Else ' Do nothing. End Select ' Set the ToolTip property of the employee's photo. If employeePhoto IsNot Nothing Then employeePhoto.ToolTip = rowView("FirstName").ToString() & " " & _ rowView("LastName").ToString() End If End Sub </script> <html> <body> <form runat="server"> <h3>FormViewRow Example</h3> <asp:formview id="EmployeeFormView" datasourceid="EmployeeSource" allowpaging="true" datakeynames="EmployeeID" emptydatatext="No employees found." ondatabound="EmployeeFormView_DataBound" runat="server"> <itemtemplate> <table> <tr> <td rowspan="6"> <asp:image id="EmployeeImage" imageurl='<%# Eval("PhotoPath") %>' 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 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") %>' 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 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> </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], [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#" %> <%@ import namespace="System.Data" %> <script runat="server"> void EmployeeFormView_DataBound(Object sender, EventArgs e) { // Use the Row property to retrieve the data row from // the FormView control. FormViewRow row = EmployeeFormView.Row; // Get the data item bound to the FormView control. DataRowView rowView = (DataRowView)EmployeeFormView.DataItem; // Retrieve the Image control from the appropriate template // based on the current mode. Image employeePhoto = null; switch(EmployeeFormView.CurrentMode) { case FormViewMode.ReadOnly: employeePhoto = (Image)row.FindControl("EmployeeImage"); break; case FormViewMode.Edit: employeePhoto = (Image)row.FindControl("EmployeeEditImage"); break; default: // Do nothing. break; } // Set the ToolTip property of the employee's photo. if (employeePhoto != null) { employeePhoto.ToolTip = rowView["FirstName"].ToString() + " " + rowView["LastName"].ToString(); } } </script> <html> <body> <form runat="server"> <h3>FormViewRow Example</h3> <asp:formview id="EmployeeFormView" datasourceid="EmployeeSource" allowpaging="true" datakeynames="EmployeeID" emptydatatext="No employees found." ondatabound="EmployeeFormView_DataBound" runat="server"> <itemtemplate> <table> <tr> <td rowspan="6"> <asp:image id="EmployeeImage" imageurl='<%# Eval("PhotoPath") %>' 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 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") %>' 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 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> </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], [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>


System.Web.UI.Control
System.Web.UI.WebControls.WebControl
System.Web.UI.WebControls.TableRow
System.Web.UI.WebControls.FormViewRow
System.Web.UI.WebControls.FormViewPagerRow


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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


FormViewRow コンストラクタ
アセンブリ: System.Web (system.web.dll 内)

Public Sub New ( _ itemIndex As Integer, _ rowType As DataControlRowType, _ rowState As DataControlRowState _ )
Dim itemIndex As Integer Dim rowType As DataControlRowType Dim rowState As DataControlRowState Dim instance As New FormViewRow(itemIndex, rowType, rowState)
public function FormViewRow ( itemIndex : int, rowType : DataControlRowType, rowState : DataControlRowState )


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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


FormViewRow プロパティ



FormViewRow メソッド



FormViewRow メンバ
FormViewRow データ型で公開されるメンバを以下の表に示します。






名前 | 説明 | |
---|---|---|
![]() | DataBinding | サーバー コントロールがデータ ソースに連結すると発生します。(Control から継承されます。) |
![]() | Disposed | サーバー コントロールがメモリから解放されると発生します。これは、ASP.NET ページが要求されている場合のサーバー コントロールの有効期間における最終段階です。(Control から継承されます。) |
![]() | Init | サーバー コントロールが初期化されると発生します。これは、サーバー コントロールの有効期間における最初の手順です。(Control から継承されます。) |
![]() | Load | サーバー コントロールが Page オブジェクトに読み込まれると発生します。(Control から継承されます。) |
![]() | PreRender | Control オブジェクトの読み込み後、表示を開始する前に発生します。(Control から継承されます。) |
![]() | Unload | サーバー コントロールがメモリからアンロードされると発生します。(Control から継承されます。) |

Weblioに収録されているすべての辞書からFormViewRowを検索する場合は、下記のリンクをクリックしてください。

- FormViewRowのページへのリンク