HyperLinkField.DataNavigateUrlFormatString プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > HyperLinkField.DataNavigateUrlFormatString プロパティの意味・解説 

HyperLinkField.DataNavigateUrlFormatString プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

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

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

Public Overridable Property
 DataNavigateUrlFormatString As String
Dim instance As HyperLinkField
Dim value As String

value = instance.DataNavigateUrlFormatString

instance.DataNavigateUrlFormatString = value
public virtual string DataNavigateUrlFormatString
 { get; set; }
public:
virtual property String^ DataNavigateUrlFormatString {
    String^ get ();
    void set (String^ value);
}
/** @property */
public String get_DataNavigateUrlFormatString ()

/** @property */
public void set_DataNavigateUrlFormatString
 (String value)
public function get DataNavigateUrlFormatString
 () : String

public function set DataNavigateUrlFormatString
 (value : String)

プロパティ
HyperLinkField オブジェクト表示されるハイパーリンクURL適用する書式指定文字列既定値空の文字列です ("")。この値は、URL 値に適用される特定の書式設定されていないことを示します

解説解説

HyperLinkField オブジェクト表示されるハイパーリンクURLカスタム書式指定するには、DataNavigateUrlFormatString プロパティ使用しますDataNavigateUrlFormatString プロパティ設定されていない場合ハイパーリンクURL には特別な書式一切適用されません。

メモメモ

DataNavigateUrlFields プロパティ設定した場合限り書式指定文字列適用されます。

書式指定文字列には、任意のリテラル文字列使用でき、通常は、フィールド値のプレースホルダが含まれます。たとえば、"Item Value: {0}" という書式指定文字列があった場合、"{0}" のプレースホルダは、対応するフィールドの値と置き換えられ上でHyperLinkField オブジェクト表示されます。書式指定文字列残り部分は、リテラル テキストとして表示されます。

プレースホルダは、{ A : Bxx } の形式で、中かっこ囲まれた、コロン区切り2 つ部分から構成されます。コロンの前の値 (一般的な例での A) は 0 から始まるパラメータリストフィールドインデックス指定します

メモメモ

このパラメータは、書式指定構文一部です。各セルフィールド値を 1 つしか格納できないので、この値は必ず 0 に設定します

コロンおよびコロンの後の値は省略可能です。コロンの後の文字 (一般的な例での B) には、値を表示する際に使用する書式指定します。共通の書式次の表に示します

書式指定文字の後の値 (一般的な例での xx) は、表示する有効桁数または小数点指定します。たとえば、書式指定文字列 "{0:F2}" を使用すると、2 固定小数点数表示されます。

書式指定文字列詳細については、「書式設定概要」を参照してください

使用例使用例

HyperLinkField オブジェクト表示されるハイパーリンクナビゲーション URL対しDataNavigateUrlFormatString プロパティ使用してカスタム書式指定する方法次のコード例示します。DataTextField プロパティ指定されフィールドの値は、書式指定文字列指定されWeb ページクエリ文字列として渡されます。

<%@ Page language="VB" %>

<html>
  <body>
    <form 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>

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

<html>
  <body>
    <form 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>

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
HyperLinkField クラス
HyperLinkField メンバ
System.Web.UI.WebControls 名前空間
HyperLinkField.DataNavigateUrlFields プロパティ
DataTextField
DataTextFormatString
NavigateUrl
Target
Text



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

辞書ショートカット

すべての辞書の索引

「HyperLinkField.DataNavigateUrlFormatString プロパティ」の関連用語

HyperLinkField.DataNavigateUrlFormatString プロパティのお隣キーワード
検索ランキング

   

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



HyperLinkField.DataNavigateUrlFormatString プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS