HyperLinkField クラス

定義

データ バインド コントロール内にハイパーリンクとして表示されるフィールドを表します。

public ref class HyperLinkField : System::Web::UI::WebControls::DataControlField
public class HyperLinkField : System.Web.UI.WebControls.DataControlField
type HyperLinkField = class
    inherit DataControlField
Public Class HyperLinkField
Inherits DataControlField
継承
HyperLinkField

次のコード例は、オブジェクトを HyperLinkField 使用して、コントロール内の静的ハイパーリンクの列を表示する方法を GridView 示しています。 オブジェクト内の HyperLinkField 各ハイパーリンクは、それぞれ、プロパティで指定された Text 同じキャプションと NavigateUrl ナビゲーション URL を共有します。


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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>HyperLinkField Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>HyperLinkField Example</h3>
                    
      <!-- Populate the Columns collection declaratively. -->
      <!-- Set the HyperLinkField field column to a static     -->
      <!-- caption and URL.                                    -->
      <asp:gridview id="OrdersGridView" 
        datasourceid="OrdersSqlDataSource" 
        autogeneratecolumns="false"
        runat="server">
                
        <columns>
                
          <asp:boundfield datafield="OrderID" 
            headertext="OrderID"/>
          <asp:boundfield datafield="CustomerID" 
            headertext="Customer ID"/>
          <asp:boundfield datafield="OrderDate" 
            headertext="Order Date"
            dataformatstring="{0:d}" />
          <asp:hyperlinkfield text="Details..."
            navigateurl="~\details.aspx"            
            headertext="Order Details"
            target="_blank" />
                
        </columns>
                
      </asp:gridview>
            
      <!-- This example uses Microsoft SQL Server and connects -->
      <!-- to the Northwind sample database.                   -->
      <asp:sqldatasource id="OrdersSqlDataSource"  
        selectcommand="SELECT [OrderID], [CustomerID], [OrderDate] FROM [Orders]"
        connectionstring="server=localhost;database=northwind;integrated security=SSPI"
        runat="server">
      </asp:sqldatasource>
            
    </form>
  </body>
</html>

<%@ Page language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>HyperLinkField Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>HyperLinkField Example</h3>
                    
      <!-- Populate the Columns collection declaratively. -->
      <!-- Set the HyperLinkField field column to a static     -->
      <!-- caption and URL.                                    -->
      <asp:gridview id="OrdersGridView" 
        datasourceid="OrdersSqlDataSource" 
        autogeneratecolumns="false"
        runat="server">
                
        <columns>
                
          <asp:boundfield datafield="OrderID" 
            headertext="OrderID"/>
          <asp:boundfield datafield="CustomerID" 
            headertext="Customer ID"/>
          <asp:boundfield datafield="OrderDate" 
            headertext="Order Date"
            dataformatstring="{0:d}" />
          <asp:hyperlinkfield text="Details..."
            navigateurl="~\details.aspx"            
            headertext="Order Details"
            target="_blank" />
                
        </columns>
                
      </asp:gridview>
            
      <!-- This example uses Microsoft SQL Server and connects -->
      <!-- to the Northwind sample database.                   -->
      <asp:sqldatasource id="OrdersSqlDataSource"  
        selectcommand="SELECT [OrderID], [CustomerID], [OrderDate] FROM [Orders]"
        connectionstring="server=localhost;database=northwind;integrated security=SSPI"
        runat="server">
      </asp:sqldatasource>
            
    </form>
  </body>
</html>

次のコード例は、データ ソース内の HyperLinkField フィールドにオブジェクトをバインドする方法を示しています。 プロパティ DataTextField は、キャプションに DataNavigateUrlFields バインドするフィールドと、オブジェクトに表示される HyperLinkField 各ハイパーリンクのナビゲーション URL をそれぞれ指定するために使用されます。


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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>HyperLinkField Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>HyperLinkField Example</h3>
                    
      <!-- Populate the Columns collection declaratively. -->
      <!-- The UnitPrice field values are bound to the         -->
      <!-- captions of the hyperlinks in the HyperLinkField    -->
      <!-- field column, formatted as currency. The ProductID  -->
      <!-- field values are bound to the navigate URLs of the  -->
      <!-- hyperlinks. However, instead of being the actual    -->
      <!-- URL values, the product ID is passed to the linked  -->
      <!-- page as a parameter in the URL specified by the     -->
      <!-- DataNavigateUrlFormatString property.               -->
      <asp:gridview id="OrdersGridView" 
        datasourceid="OrdersSqlDataSource" 
        autogeneratecolumns="false"
        runat="server">
                
        <columns>
                
          <asp:boundfield datafield="OrderID" 
            headertext="Order ID"/>
          <asp:boundfield datafield="ProductID" 
            headertext="Product ID"/>
          <asp:hyperlinkfield datatextfield="UnitPrice"
            datatextformatstring="{0:c}"
            datanavigateurlfields="ProductID"
            datanavigateurlformatstring="~\details.aspx?ProductID={0}"          
            headertext="Price"
            target="_blank" />
          <asp:boundfield datafield="Quantity" 
            headertext="Quantity"/>
                 
        </columns>
                
      </asp:gridview>
            
      <!-- This example uses Microsoft SQL Server and connects -->
      <!-- to the Northwind sample database.                   -->
      <asp:sqldatasource id="OrdersSqlDataSource"  
        selectcommand="SELECT [OrderID], [ProductID], [UnitPrice], [Quantity] FROM [Order Details]"
        connectionstring="server=localhost;database=northwind;integrated security=SSPI"
        runat="server">
      </asp:sqldatasource>
            
    </form>
  </body>
</html>

<%@ Page language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
  <head runat="server">
    <title>HyperLinkField DataTextFormatString and DataNavigateUrlFormatString Example</title>
</head>
<body>
    <form id="form1" runat="server">
        
      <h3>HyperLinkField DataTextFormatString and DataNavigateUrlFormatString Example</h3>
                    
      <!-- Populate the Columns collection declaratively. -->
      <!-- The UnitPrice field values are bound to the         -->
      <!-- captions of the hyperlinks in the HyperLinkField    -->
      <!-- field column, formatted as currency. The ProductID  -->
      <!-- field values are bound to the navigate URLs of the  -->
      <!-- hyperlinks. However, instead of being the actual    -->
      <!-- URL values, the product ID is passed to the linked  -->
      <!-- page as a parameter in the URL specified by the     -->
      <!-- DataNavigateUrlFormatString property.               -->
      <asp:gridview id="OrdersGridView" 
        datasourceid="OrdersSqlDataSource" 
        autogeneratecolumns="false"
        runat="server">
                
        <columns>
                
          <asp:boundfield datafield="OrderID" 
            headertext="Order ID"/>
          <asp:boundfield datafield="ProductID" 
            headertext="Product ID"/>
          <asp:hyperlinkfield datatextfield="UnitPrice"
            datatextformatstring="{0:c}"
            datanavigateurlfields="ProductID"
            datanavigateurlformatstring="~\details.aspx?ProductID={0}"          
            headertext="Price"
            target="_blank" />
          <asp:boundfield datafield="Quantity" 
            headertext="Quantity"/>
                 
        </columns>
                
      </asp:gridview>
            
      <!-- This example uses Microsoft SQL Server and connects -->
      <!-- to the Northwind sample database.                   -->
      <asp:sqldatasource id="OrdersSqlDataSource"  
        selectcommand="SELECT [OrderID], [ProductID], [UnitPrice], [Quantity] FROM [Order Details]"
        connectionstring="server=localhost;database=northwind;integrated security=SSPI"
        runat="server">
      </asp:sqldatasource>
            
    </form>
  </body>
</html>

注釈

このHyperLinkFieldクラスは、表示される各レコードのハイパーリンクを表示するために、データ バインド コントロール (などGridViewDetailsView) によって使用されます。 ユーザーがハイパーリンクをクリックすると、ハイパーリンクに関連付けられている Web ページに移動します。 オブジェクトは HyperLinkField 、使用されているデータ バインド コントロールによって異なる方法で表示されます。 たとえば、コントロールは GridView オブジェクトを HyperLinkField 列として表示し、コントロールはオブジェクトを DetailsView 行として表示します。

ハイパーリンクに表示するキャプションを指定するには、プロパティを Text 使用します。 このプロパティを NavigateUrl 使用して、ハイパーリンクがクリックされたときに移動する URL を指定します。 リンクされたコンテンツを特定のウィンドウまたはフレームに表示する場合は、プロパティを設定します Target

注意

プロパティをTextNavigateUrl設定すると、オブジェクト内のすべてのハイパーリンクがHyperLinkField同じキャプションとナビゲーション URL を共有します。 同様に、この Target プロパティはすべてのハイパーリンクにも適用されます。

または、データ ソース内のフィールドに HyperLinkField オブジェクトをバインドすることもできます。 これにより、オブジェクト内のハイパーリンクごとに異なるキャプションを HyperLinkField 表示し、各ハイパーリンクを別の場所に移動することができます。 フィールドをキャプションにバインドするには、プロパティを設定します DataTextField 。 ナビゲーション用の URL を作成するには、URL の DataNavigateUrlFields 作成に使用するフィールドのコンマ区切りのリストにプロパティを設定します。

キャプションとナビゲーション URL のカスタム形式は、それぞれ設定DataTextFormatStringDataNavigateUrlFormatStringして指定できます。

You can hide a HyperLinkField object in a data-bound control by setting the Visible property to false.

オブジェクトのヘッダーセクションとフッターセクションを HyperLinkField カスタマイズできます。 ヘッダーセクションまたはフッターセクションにキャプションを表示するには、それぞれプロパティをHeaderTextFooterText設定します。 テキストの代わりにヘッダー セクションに画像を表示するには、プロパティを設定します HeaderImageUrl 。 ヘッダー セクションは、プロパティfalseを にHyperLinkField設定することで、オブジェクト内でShowHeader非表示にすることができます。

注意

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

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

Style プロパティ [説明]
ControlStyle オブジェクトの子 Web サーバー コントロールの HyperLinkField スタイル設定。
FooterStyle オブジェクトのフッター セクションの HyperLinkField スタイル設定。
HeaderStyle オブジェクトのヘッダー セクションの HyperLinkField スタイル設定。
ItemStyle オブジェクト内 HyperLinkField のデータ項目のスタイル設定。

コンストラクター

HyperLinkField()

HyperLinkField クラスの新しいインスタンスを初期化します。

プロパティ

AccessibleHeaderText

一部のコントロールの AbbreviatedText プロパティ値として表示されるテキストを取得または設定します。

(継承元 DataControlField)
Control

DataControlField オブジェクトが関連付けられているデータ コントロールの参照を取得します。

(継承元 DataControlField)
ControlStyle

DataControlField オブジェクトに格納されているすべての Web サーバー コントロールのスタイルを取得します。

(継承元 DataControlField)
DataNavigateUrlFields

HyperLinkField オブジェクトに表示されるハイパーリンクの URL を構築するために使用する、データ ソース内のフィールド名を取得または設定します。

DataNavigateUrlFormatString

HyperLinkField オブジェクトに表示されるハイパーリンクの URL に対して書式を指定する文字列を取得または設定します。

DataTextField

HyperLinkField オブジェクトに表示されるハイパーリンクのキャプションとして使用するテキストが格納されている、データ ソース内のフィールド名を取得または設定します。

DataTextFormatString

HyperLinkField オブジェクトに表示されるハイパーリンクのキャプションに適用する書式指定文字列を取得または設定します。

DesignMode

デザイン時環境で、現在データ コントロール フィールドが表示されているかどうかを示す値を取得します。

(継承元 DataControlField)
FooterStyle

データ コントロール フィールドのフッターのスタイルを取得または設定します。

(継承元 DataControlField)
FooterText

データ コントロール フィールドのフッター項目に表示されるテキストを取得または設定します。

(継承元 DataControlField)
HeaderImageUrl

データ コントロール フィールドのヘッダー項目に表示されるイメージの URL を取得または設定します。

(継承元 DataControlField)
HeaderStyle

データ コントロール フィールドのヘッダーのスタイルを取得または設定します。

(継承元 DataControlField)
HeaderText

データ コントロール フィールドのヘッダー項目に表示されるテキストを取得または設定します。

(継承元 DataControlField)
InsertVisible

DataControlField オブジェクトの親データ バインド コントロールが挿入モードの場合に、このオブジェクトが表示されるかどうかを示す値を取得します。

(継承元 DataControlField)
IsTrackingViewState

DataControlField オブジェクトがビューステートへの変更を保存しているかどうかを示す値を取得します。

(継承元 DataControlField)
ItemStyle

データ コントロール フィールドで表示されるテキスト ベースの内容のスタイルを取得します。

(継承元 DataControlField)
NavigateUrl

HyperLinkField オブジェクトのハイパーリンクがクリックされたときの移動先 URL を取得または設定します。

ShowHeader

データ コントロール フィールドのヘッダー項目を表示するかどうかを示す値を取得または設定します。

(継承元 DataControlField)
SortExpression

データ ソース コントロールでデータを並べ替えるために使用される並べ替え式を、取得または設定します。

(継承元 DataControlField)
Target

HyperLinkField オブジェクトのハイパーリンクがクリックされたときに、リンク先の Web ページを表示するウィンドウまたはフレームを取得または設定します。

Text

HyperLinkField オブジェクトの各ハイパーリンクに表示されるテキストを取得または設定します。

ValidateRequestMode

コントロールでクライアントの入力を検証するかどうかを指定する値を取得または設定します。

(継承元 DataControlField)
ViewState

同一のページに対する複数の要求にわたって、DataControlField オブジェクトのビューステートを保存し、復元できるようにする状態情報のディクショナリを取得します。

(継承元 DataControlField)
Visible

データ コントロール フィールドを表示するかどうかを示す値を取得または設定します。

(継承元 DataControlField)

メソッド

CloneField()

現在の DataControlField 派生オブジェクトのコピーを作成します。

(継承元 DataControlField)
CopyProperties(DataControlField)

HyperLinkField オブジェクトの現在のプロパティを、指定されたオブジェクトにコピーします。

CreateField()

HyperLinkField クラスの新しいインスタンスを返します。

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
ExtractValuesFromCell(IOrderedDictionary, DataControlFieldCell, DataControlRowState, Boolean)

現在のテーブル セルからデータ コントロール フィールドの値を抽出し、指定した IDictionary コレクションにその値を追加します。

(継承元 DataControlField)
FormatDataNavigateUrlValue(Object[])

DataNavigateUrlFormatString プロパティに指定された書式指定文字列を使って、ナビゲーション URL に書式を適用します。

FormatDataTextValue(Object)

DataTextFormatString プロパティに指定された書式指定文字列を使って、キャプション テキストに書式を適用します。

GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
Initialize(Boolean, Control)

HyperLinkField オブジェクトを初期化します。

InitializeCell(DataControlFieldCell, DataControlCellType, DataControlRowState, Int32)

HyperLinkField オブジェクト内のセルを初期化します。

LoadViewState(Object)

データ ソース ビューの、以前保存したビューステートを復元します。

(継承元 DataControlField)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
OnFieldChanged()

FieldChanged イベントを発生させます。

(継承元 DataControlField)
SaveViewState()

ページがサーバーにポストバックされた時間以降に発生した、DataControlField ビューステートへの変更を保存します。

(継承元 DataControlField)
ToString()

この DataControlField オブジェクトを表す文字列を返します。

(継承元 DataControlField)
TrackViewState()

DataControlField オブジェクトがそのビューステートの変更を追跡するようにします。それにより、変更をコントロールの ViewState プロパティに格納して、同じページに対する複数の要求にわたって永続化できます。

(継承元 DataControlField)
ValidateSupportsCallback()

HyperLinkField オブジェクトに格納されているコントロールがコールバックをサポートしているかどうかを示します。

明示的なインターフェイスの実装

IDataSourceViewSchemaAccessor.DataSourceViewSchema

DataControlField オブジェクトに関連付けられているスキーマを取得または設定します。

(継承元 DataControlField)
IStateManager.IsTrackingViewState

DataControlField オブジェクトがビューステートへの変更を保存しているかどうかを示す値を取得します。

(継承元 DataControlField)
IStateManager.LoadViewState(Object)

データ コントロール フィールドの、以前保存したビューステートを復元します。

(継承元 DataControlField)
IStateManager.SaveViewState()

ページがサーバーにポストバックされた時間以降に発生した、DataControlField ビューステートへの変更を保存します。

(継承元 DataControlField)
IStateManager.TrackViewState()

DataControlField オブジェクトがそのビューステートの変更を追跡するようにします。それにより、変更をコントロールの ViewState プロパティに格納して、同じページに対する複数の要求にわたって永続化できます。

(継承元 DataControlField)

適用対象

こちらもご覧ください