DetailsViewRow イベント

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

DetailsViewRow クラス
アセンブリ: System.Web (system.web.dll 内)


DetailsViewRow クラスは、DetailsView コントロールの個別の行を表すために使用されます。DetailsView コントロールの各行には、行の種類が指定されています。DetailsView コントロールで有効な行の種類を次の表に示します。
行の種類 | |
---|---|
DataRow | |
EmptyDataRow | DetailsView コントロールの空のデータ行。空のデータ行は、表示するレコードがない場合に DetailsView コントロールに表示されます。 |
DetailsViewRow オブジェクトの行の種類を確認するには、RowType プロパティを使用します。DetailsViewRow オブジェクトには、状態も関連付けられます。状態は、次の表に示す値のビットごとの組み合わせになります。
状態の値 | |
---|---|
DetailsViewRow オブジェクトの状態を確認するには、RowState プロパティを使用します。
DetailsView コントロールは、そのすべてのデータ行を Rows コレクションに格納します。Rows コレクション内の DetailsViewRow オブジェクトのインデックスを確認するには、RowIndex プロパティを使用します。
Cells プロパティを使用して、DetailsViewRow オブジェクトの個別のセルにアクセスできます。セルにコントロールが格納されている場合は、セルの Controls コレクションを使用して、セルからコントロールを取得できます。コントロールに ID プロパティが指定されている場合は、セルの FindControl メソッドを使用してコントロールを検索することもできます。
BoundField フィールドの列、または自動的に生成されたフィールドの列からフィールド値を取得するには、セルの Text プロパティを使用します。フィールド値がコントロールにバインドされている、その他の種類のフィールドの列からフィールド値を取得するには、最初に適切なセルからコントロールを取得し、次にコントロールの適切なプロパティにアクセスします。
![]() |
---|
値をコントロールのプロパティにバインドせずに、TemplateField フィールドの列でデータ バインディング式を直接使用できます。この場合、フィールド値は DataBoundLiteralControl コントロールに自動的に入ります。フィールド値を取得するには、最初に DataBoundLiteralControl コントロールを適切なセルから取得してから、その Text プロパティを使用する必要があります。 |
DetailsViewRow クラスのインスタンスの初期プロパティ値の一覧については、DetailsViewRow コンストラクタのトピックを参照してください。

フィールド値を DetailsViewRow オブジェクトから取得する方法のコード例を次に示します。
<%@ page language="VB" %> <script runat="server"> Sub SubmitButton_Click(ByVal sender As Object, ByVal e As EventArgs) ' Use the Count property to determine whether the ' Rows collection contains any item. If ItemDetailsView.Rows.Count > 0 Then ' Iterate through the Rows collection and display ' the value of each field. MessageLabel.Text = "The row values are: <br/><br/>" Dim row As DetailsViewRow For Each row In ItemDetailsView.Rows ' Use the Text property to access the value of ' each cell. In this example, the cells in the ' first column (index 0) contains the field names, ' while the cells in the second column (index 1) ' contains the field value. MessageLabel.Text &= row.Cells(0).Text & " = " & _ row.Cells(1).Text & "<br/>" Next Else MessageLabel.Text = "No items." End If End Sub </script> <html> <body> <form runat="server"> <h3>DetailsViewRow Example</h3> <asp:detailsview id="ItemDetailsView" datasourceid="DetailsViewSource" allowpaging="true" autogeneraterows="false" runat="server"> <fields> <asp:boundfield datafield="CustomerID" headertext="Customer ID"/> <asp:boundfield datafield="CompanyName" headertext="Company Name"/> <asp:boundfield datafield="Address" headertext="Address"/> <asp:boundfield datafield="City" headertext="City"/> <asp:boundfield datafield="PostalCode" headertext="ZIP Code"/> <asp:boundfield datafield="Country" headertext="Country"/> </fields> </asp:detailsview> <br/> <asp:button id="SubmitButton" text="Display Row Values" onclick="SubmitButton_Click" runat="server"/> <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="DetailsViewSource" selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]" connectionstring= "<%$ ConnectionStrings:NorthWindConnectionString%>" runat="server"/> </form> </body> </html>
<%@ page language="C#" %> <script runat="server"> void SubmitButton_Click(Object sender, EventArgs e) { // Use the Count property to determine whether the // Rows collection contains any item. if (ItemDetailsView.Rows.Count > 0) { // Iterate through the Rows collection and display // the value of each field. MessageLabel.Text = "The row values are: <br/><br/>"; foreach (DetailsViewRow row in ItemDetailsView.Rows) { // Use the Text property to access the value of // each cell. In this example, the cells in the // first column (index 0) contains the field names, // while the cells in the second column (index 1) // contains the field value. MessageLabel.Text += row.Cells[0].Text + " = " + row.Cells[1].Text + "<br/>"; } } else { MessageLabel.Text = "No items."; } } </script> <html> <body> <form runat="server"> <h3>DetailsViewRow Example</h3> <asp:detailsview id="ItemDetailsView" datasourceid="DetailsViewSource" allowpaging="true" autogeneraterows="false" runat="server"> <fields> <asp:boundfield datafield="CustomerID" headertext="Customer ID"/> <asp:boundfield datafield="CompanyName" headertext="Company Name"/> <asp:boundfield datafield="Address" headertext="Address"/> <asp:boundfield datafield="City" headertext="City"/> <asp:boundfield datafield="PostalCode" headertext="ZIP Code"/> <asp:boundfield datafield="Country" headertext="Country"/> </fields> </asp:detailsview> <br/> <asp:button id="SubmitButton" text="Display Row Values" onclick="SubmitButton_Click" runat="server"/> <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="DetailsViewSource" selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]" connectionstring= "<%$ ConnectionStrings:NorthWindConnectionString%>" runat="server"/> </form> </body> </html>
ヘッダー行を表す DetailsViewRow オブジェクトから Image コントロールを取得する方法のコード例を次に示します。Image コントロールはヘッダー テンプレートで宣言されます。
<%@ page language="VB" %> <script runat="server"> Sub ItemDetailsView_ItemCreated(ByVal sender As Object, ByVal e As EventArgs) ' Retrieve the header row. Dim headerRow As DetailsViewRow = ItemDetailsView.HeaderRow ' Retrieve the Image control from the header row. Dim logoImage As Image = CType(headerRow.FindControl("LogoImage"), Image) ' Display a custom image to indicate whether the ' DetailsView control is in edit or read-only mode. Select Case ItemDetailsView.CurrentMode Case DetailsViewMode.Edit logoImage.ImageUrl = "~/Images/Edit.jpg" Case DetailsViewMode.ReadOnly logoImage.ImageUrl = "~/Images/ReadOnly.jpg" Case Else logoImage.ImageUrl = "~/Images/Default.jpg" End Select End Sub </script> <html> <body> <form runat="server"> <h3>DetailsViewRow Example</h3> <asp:detailsview id="ItemDetailsView" datasourceid="DetailsViewSource" allowpaging="true" autogeneraterows="false" autogenerateeditbutton="true" datakeynames="CustomerID" onitemcreated="ItemDetailsView_ItemCreated" runat="server"> <fields> <asp:boundfield datafield="CustomerID" headertext="Customer ID"/> <asp:boundfield datafield="CompanyName" headertext="Company Name"/> <asp:boundfield datafield="Address" headertext="Address"/> <asp:boundfield datafield="City" headertext="City"/> <asp:boundfield datafield="PostalCode" headertext="ZIP Code"/> <asp:boundfield datafield="Country" headertext="Country"/> </fields> <headertemplate> <asp:image id="LogoImage" imageurl="~/Images/Default.jpg" runat="server"/> </headertemplate> </asp:detailsview> <!-- 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="DetailsViewSource" selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]" updatecommand="Update [Customers] Set [CompanyName]=@CompanyName, [Address]=@Address, [City]=@City, [PostalCode]=@PostalCode, [Country]=@Country Where [CustomerID]=@CustomerID" connectionstring= "<%$ ConnectionStrings:NorthWindConnectionString%>" runat="server"/> </form> </body> </html>
<%@ page language="C#" %> <script runat="server"> void ItemDetailsView_ItemCreated(Object sender, EventArgs e) { // Retrieve the header row. DetailsViewRow headerRow = ItemDetailsView.HeaderRow; // Retrieve the Image control from the header row. Image logoImage = (Image)headerRow.FindControl("LogoImage"); // Display a custom image to indicate whether the // DetailsView control is in edit or read-only mode. switch (ItemDetailsView.CurrentMode) { case DetailsViewMode.Edit: logoImage.ImageUrl = "~/Images/Edit.jpg"; break; case DetailsViewMode.ReadOnly: logoImage.ImageUrl = "~/Images/ReadOnly.jpg"; break; default: logoImage.ImageUrl = "~/Images/Default.jpg"; break; } } </script> <html> <body> <form runat="server"> <h3>DetailsViewRow Example</h3> <asp:detailsview id="ItemDetailsView" datasourceid="DetailsViewSource" allowpaging="true" autogeneraterows="false" autogenerateeditbutton="true" datakeynames="CustomerID" onitemcreated="ItemDetailsView_ItemCreated" runat="server"> <fields> <asp:boundfield datafield="CustomerID" headertext="Customer ID"/> <asp:boundfield datafield="CompanyName" headertext="Company Name"/> <asp:boundfield datafield="Address" headertext="Address"/> <asp:boundfield datafield="City" headertext="City"/> <asp:boundfield datafield="PostalCode" headertext="ZIP Code"/> <asp:boundfield datafield="Country" headertext="Country"/> </fields> <headertemplate> <asp:image id="LogoImage" imageurl="~/Images/Default.jpg" runat="server"/> </headertemplate> </asp:detailsview> <!-- 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="DetailsViewSource" selectcommand="Select [CustomerID], [CompanyName], [Address], [City], [PostalCode], [Country] From [Customers]" updatecommand="Update [Customers] Set [CompanyName]=@CompanyName, [Address]=@Address, [City]=@City, [PostalCode]=@PostalCode, [Country]=@Country Where [CustomerID]=@CustomerID" 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.DetailsViewRow
System.Web.UI.WebControls.DetailsViewPagerRow


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


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

Public Sub New ( _ rowIndex As Integer, _ rowType As DataControlRowType, _ rowState As DataControlRowState _ )
Dim rowIndex As Integer Dim rowType As DataControlRowType Dim rowState As DataControlRowState Dim instance As New DetailsViewRow(rowIndex, rowType, rowState)
public function DetailsViewRow ( rowIndex : 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 によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


DetailsViewRow プロパティ



DetailsViewRow メソッド



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






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

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

- DetailsViewRowのページへのリンク