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

BoundField クラス

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

データ バインド コントロールテキストとして表示するフィールド表します

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

Public Class BoundField
    Inherits DataControlField
public class BoundField : DataControlField
public ref class BoundField : public
 DataControlField
public class BoundField extends DataControlField
public class BoundField extends
 DataControlField
解説解説

BoundField クラスフィールドの値をテキストとして表示するために、データ バインド コントロール (GridView、DetailsView など) で使用されます。BoundField オブジェクトは、それが使用されているデータ バインド コントロールによって表示異なります。たとえば、BoundField オブジェクトは、GridView コントロールでは列として表示されDetailsView コントロールでは行として表示されます。

BoundField オブジェクト表示するフィールド指定するには、DataField プロパティフィールドの名前に設定しますフィールド値を表示する前に HTML エンコードするには、HtmlEncode プロパティtrue設定しますカスタム書式指定文字列フィールド値に適用するには、DataFormatString プロパティ設定しますHtmlEncode プロパティtrue場合エンコードされた、フィールド文字列値がカスタム書式指定文字列使用されます。既定では、データ バインド コントロール読み取り専用モード場合だけ、書式指定文字列フィールド値に適用されます。データ バインド コントロール編集モード場合書式指定文字列表示値に適用するには、ApplyFormatInEditMode プロパティtrue設定しますフィールド値が null場合カスタムキャプション表示するには、NullDisplayText プロパティ設定しますBoundField オブジェクトは、ConvertEmptyStringToNull プロパティtrue設定することにより、空の文字列 ("") フィールド値を null 値自動的に変換します

データ バインド コントロール内の BoundField オブジェクトを非表示にするには、Visible プロパティfalse設定します編集モードフィールドの値が変更されるのを防ぐにはReadOnly プロパティtrue設定しますレコード挿入サポートするデータ バインド コントロール (DetailsView コントロールなど) で BoundField オブジェクトを非表示にするには、InsertVisible プロパティfalse設定します挿入モード自動生成されたキー フィールドを非表示にする場合は、通常この方法を使用します

BoundField オブジェクトヘッダー セクションフッター セクションカスタマイズできますヘッダー セクションキャプション表示するには、HeaderText プロパティ設定しますフッター セクションキャプション表示するには、FooterText プロパティ設定しますヘッダー セクションテキスト表示する代わりに、HeaderImageUrl プロパティ設定してイメージ表示できます。ShowHeader プロパティfalse設定することにより、BoundField オブジェクトヘッダー セクションを非表示できます

メモメモ

一部データ バインド コントロール (GridView コントロールなど) では、コントロールヘッダー セクション全体表示または非表示できます。これらのデータ バインド コントロールは、個別バインドされたフィールドShowHeader プロパティサポートしません。データ バインド コントロールヘッダー セクション (存在する場合) 全体表示または非表示にするには、コントロールShowHeader プロパティ使用します

フィールド各部分にスタイル プロパティ設定することにより、BoundField オブジェクト外観 (フォントの色や背景色など) をカスタマイズすることもできますさまざまなスタイル プロパティの一覧を次の表に示します

使用例使用例

BoundField オブジェクト使用してGridView コントロールフィールドの値を表示するコード例次に示します

<%@ Page language="VB" %>

<html>
  <body>
    <form runat="server">
        
      <h3>BoundField Example</h3>

      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSqlDataSource" 
        autogeneratecolumns="false"
        autogenerateeditbutton="true"
        allowpaging="true" 
        datakeynames="CustomerID"  
        runat="server">
         
        <columns>
          <asp:boundfield datafield="CustomerID"
            readonly="true"   
   
            headertext="Customer ID"/>
          <asp:boundfield datafield="CompanyName"
            convertemptystringtonull="true"
            headertext="Customer Name"/>
          <asp:boundfield datafield="Address"
            convertemptystringtonull="true"
            headertext="Address"/>
          <asp:boundfield datafield="City"
            convertemptystringtonull="true"
            headertext="City"/>
          <asp:boundfield datafield="PostalCode"
            convertemptystringtonull="true"
            headertext="ZIP Code"/>
          <asp:boundfield datafield="Country"
            convertemptystringtonull="true"
            headertext="Country"/>
        </columns>
                
      </asp:gridview>
            
      <!-- 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="CustomersSqlDataSource"
  
        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">
      </asp:sqldatasource>
            
    </form>
  </body>
</html>

<%@ Page language="C#" %>

<html>
  <body>
    <form runat="server">
        
      <h3>BoundField Example</h3>

      <asp:gridview id="CustomersGridView" 
        datasourceid="CustomersSqlDataSource" 
        autogeneratecolumns="false"
        autogenerateeditbutton="true"
        allowpaging="true" 
        datakeynames="CustomerID"  
        runat="server">
         
        <columns>
          <asp:boundfield datafield="CustomerID"
            readonly="true"      
            headertext="Customer ID"/>
          <asp:boundfield datafield="CompanyName"
            convertemptystringtonull="true"
            headertext="Customer Name"/>
          <asp:boundfield datafield="Address"
            convertemptystringtonull="true"
            headertext="Address"/>
          <asp:boundfield datafield="City"
            convertemptystringtonull="true"
            headertext="City"/>
          <asp:boundfield datafield="PostalCode"
            convertemptystringtonull="true"
            headertext="ZIP Code"/>
          <asp:boundfield datafield="Country"
            convertemptystringtonull="true"
            headertext="Country"/>
        </columns>
                
      </asp:gridview>
            
      <!-- 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="CustomersSqlDataSource"  
        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">
      </asp:sqldatasource>
            
    </form>
  </body>
</html>

.NET Framework のセキュリティ.NET Frameworkセキュリティ
継承階層継承階層
System.Object
   System.Web.UI.WebControls.DataControlField
    System.Web.UI.WebControls.BoundField
       System.Web.UI.WebControls.AutoGeneratedField
       System.Web.UI.WebControls.CheckBoxField
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
BoundField メンバ
System.Web.UI.WebControls 名前空間
GridView
Columns
DetailsView
Fields
ButtonField
CheckBoxField
CommandField
DataControlField
HyperLinkField
TemplateField
ApplyFormatInEditMode
DataField
DataFormatString
InsertVisible
NullDisplayText
ReadOnly
Text
ConvertEmptyStringToNull
Visible


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

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

辞書ショートカット

すべての辞書の索引

「BoundField クラス」の関連用語

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

   

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



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

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

©2025 GRAS Group, Inc.RSS