FormViewRow クラスとは? わかりやすく解説

FormViewRow クラス

メモ : このクラスは、.NET Framework version 2.0新しく追加されたものです。

FormView コントロール内の行を表します

名前空間: System.Web.UI.WebControls
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public Class FormViewRow
    Inherits TableRow
public class FormViewRow : TableRow
public class FormViewRow extends TableRow
public class FormViewRow extends
 TableRow
解説解説

FormViewRow クラスは、FormView コントロール個別の行を表すために使用されます。FormView コントロール各行には、行の種類指定されています。さまざまな行の種類の一覧次の表に示します

行の種類

説明

DataControlRowType.DataRow

FormView コントロールデータ行。

DataControlRowType.EmptyDataRow

FormView コントロールの空のデータ行。空のデータ行は、表示するレコードない場合FormView コントロール表示されます。

DataControlRowType.Footer

FormView コントロールフッター行。

DataControlRowType.Header

FormView コントロールヘッダー行。

DataControlRowType.Pager

FormView コントロールページ行。

FormViewRow オブジェクトの行の種類確認するには、RowType プロパティ使用しますFormViewRow オブジェクトには、状態も関連付けられます。状態は、次の表に示す値のビットごとの組み合わせなります

状態の値

説明

DataControlRowState.Edit

FormViewRow オブジェクト編集モードです。

DataControlRowState.Insert

FormViewRow オブジェクト挿入モードです。

DataControlRowState.Normal

FormViewRow オブジェクト標準 (既定) の状態です。

DataControlRowState.Selected

FormViewRow オブジェクト選択されています。

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">
                  &nbsp; 
              </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">
                  &nbsp; 
              </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">
                  &nbsp; 
              </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">
                  &nbsp; 
              </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>

.NET Framework のセキュリティ.NET Frameworkセキュリティ
継承階層継承階層
System.Object
   System.Web.UI.Control
     System.Web.UI.WebControls.WebControl
       System.Web.UI.WebControls.TableRow
        System.Web.UI.WebControls.FormViewRow
           System.Web.UI.WebControls.FormViewPagerRow
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
FormViewRow メンバ
System.Web.UI.WebControls 名前空間
FormView クラス
FormView.BottomPagerRow プロパティ
FormView.FooterRow プロパティ
FormView.HeaderRow プロパティ
FormView.Row プロパティ
FormView.TopPagerRow プロパティ
DataBoundLiteralControl
TableCell
Controls
FindControl
TableRow
Cells
ItemIndex
RowState
RowType


このページでは「.NET Framework クラス ライブラリ リファレンス」からFormViewRow クラスを検索した結果を表示しています。
Weblioに収録されているすべての辞書からFormViewRow クラスを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からFormViewRow クラス を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「FormViewRow クラス」の関連用語

FormViewRow クラスのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



FormViewRow クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS