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

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

MenuItemBinding.ValueField プロパティ

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

データ ソースからフィールドの名前を取得または設定し、MenuItemBinding オブジェクトが適用される MenuItem オブジェクトの Value プロパティにバインドします。

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

Dim instance As MenuItemBinding
Dim value As String

value = instance.ValueField

instance.ValueField = value
public string ValueField { get;
 set; }
/** @property */
public String get_ValueField ()

/** @property */
public void set_ValueField (String value)

プロパティ値
MenuItemBinding が適用される MenuItem の Value にバインドするフィールドの名前。既定値は空の文字列 ("") です。この値は、このプロパティが設定されていないことを示します。

解説解説

Menu コントロールをデータ ソースにバインドする場合、MenuItem オブジェクトの Value プロパティにバインドするフィールド名は、ValueField プロパティで指定します。レンダリング時、MenuItemBinding オブジェクトを適用した各メニュー項目の Value プロパティには、そのフィールドの対応する値が格納されます。指定した値はメニュー項目には表示されず、MenuItemBinding オブジェクトが適用されるメニュー項目の補足データ (ポストバック イベントを処理するために使用するデータなど) を格納するために使用されます。

メモメモ

Value プロパティを直接設定することで、個々のメニュー項目の値をオーバーライドできます。

データ ソースに複数のテーブルまたは属性が含まれている場合は、最初に、Depth プロパティと DataMember プロパティのいずれか、または両方を設定してバインディング基準を確立する必要があります。

このプロパティを使用して MenuItem オブジェクトの Value プロパティをフィールドにバインドする代わりに、MenuItemBinding.Value プロパティを設定して静的な値にバインドすることもできます。これにより、MenuItemBinding オブジェクトが適用される各メニュー項目に同じ値を指定できます。

使用例使用例

ValueField プロパティを使用して、メニュー項目の Value プロパティにバインドするフィールド名を指定する方法を次のコード例に示します。この例を正常に動作させるには、以下のサンプル XML データを、Menu.xml という名前のファイルにコピーする必要があります。

<%@ page language="VB" %>

<html>
  <body>
    <form runat="server">

      <h3>MenuItemBinding Example</h3>

      <asp:menu id="NavigationMenu"
        datasourceid="MenuSource"
        runat="server">
        
        <DataBindings>
        
          <asp:menuitembinding datamember="MapHomeNode"
            formatstring="({0})" 
            textfield="Title"
            valuefield="Description"
            imageurlfield="ImageUrl"
            tooltipfield="ToolTip"
            target="_self" />
          <asp:menuitembinding datamember="MapNode"
 
            depth="1"
            formatstring="[{0}]" 
            textfield="Title"
            valuefield="Description"
            imageurlfield="ImageUrl"
            tooltipfield="ToolTip"
            target="_blank"/>
          <asp:menuitembinding datamember="MapNode"
 
            depth="2"
            formatstring="<{0}>" 
            textfield="Title"
            valuefield="Description"
            imageurlfield="ImageUrl"
            tooltipfield="ToolTip"
            target="_blank"/>
          
        </DataBindings>
        
      </asp:menu>

      <asp:xmldatasource id="MenuSource"
        datafile="Menu.xml"
        runat="server"/> 

    </form>
  </body>
</html>

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

<html>
  <body>
    <form runat="server">

      <h3>MenuItemBinding Example</h3>

      <asp:menu id="NavigationMenu"
        datasourceid="MenuSource"
        runat="server">
        
        <DataBindings>
        
          <asp:menuitembinding datamember="MapHomeNode"
            formatstring="({0})" 
            textfield="Title"
            valuefield="Description"
            imageurlfield="ImageUrl"
            tooltipfield="ToolTip"
            target="_self" />
          <asp:menuitembinding datamember="MapNode" 
            depth="1"
            formatstring="[{0}]" 
            textfield="Title"
            valuefield="Description"
            imageurlfield="ImageUrl"
            tooltipfield="ToolTip"
            target="_blank"/>
          <asp:menuitembinding datamember="MapNode" 
            depth="2"
            formatstring="<{0}>" 
            textfield="Title"
            valuefield="Description"
            imageurlfield="ImageUrl"
            tooltipfield="ToolTip"
            target="_blank"/>
          
        </DataBindings>
        
      </asp:menu>

      <asp:xmldatasource id="MenuSource"
        datafile="Menu.xml"
        runat="server"/> 

    </form>
  </body>
</html>

前の例のサンプル サイト マップ データを次のコードに示します。

<MapHomeNode ImageUrl="~\Images\Home.gif"

Title="Home"

Description="Root Page"

ToolTip="Home Page">

<MapNode ImageUrl="~\Images\Music.gif"

Title="Music"

Description="Music Category"

ToolTip="Music Page">

<MapNode ImageUrl="~\Images\Classical.gif"

Title="Classical"

Description="Classical Section"

ToolTip="Classical Page"/>

<MapNode ImageUrl="~\Images\Rock.gif"

Title="Rock"

Description="Rock Section"

ToolTip="Rock Page"/>

<MapNode ImageUrl="~\Images\Jazz.gif"

Title="Jazz"

Description="Jazz Section"

ToolTip="Jazz Page"/>

</MapNode>

<MapNode ImageUrl="~\Images\Movies.gif"

Title="Movies"

Description="Movies Category"

ToolTip="Movies Page">

<MapNode ImageUrl="~\Images\Action.gif"

Title="Action"

Description="Action Section"

ToolTip="Action Page"/>

<MapNode ImageUrl="~\Images\Drama.gif"

Title="Drama"

Description="Drama Section"

ToolTip="Drama Page"/>

<MapNode ImageUrl="~\Images\Musical.gif"

Title="Musical"

Description="Musical Section"

ToolTip="Musical Page"/>

</MapNode>

</MapHomeNode>

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
MenuItemBinding クラス
MenuItemBinding メンバ
System.Web.UI.WebControls 名前空間
Menu クラス
MenuItem クラス
MenuItemBindingCollection
XmlDataSource
Menu.DataBindings プロパティ
MenuItemBinding.DataMember プロパティ
MenuItemBinding.Depth プロパティ
MenuItemBinding.FormatString プロパティ
MenuItemBinding.ImageUrl プロパティ
MenuItemBinding.ImageUrlField プロパティ
MenuItemBinding.NavigateUrl プロパティ
MenuItemBinding.NavigateUrlField プロパティ
MenuItemBinding.Target プロパティ
MenuItemBinding.Text プロパティ
MenuItemBinding.TextField プロパティ
MenuItemBinding.ToolTip プロパティ
MenuItemBinding.ToolTipField プロパティ
MenuItem.Value プロパティ
MenuItemBinding.Value プロパティ



英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

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

   

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



MenuItemBinding.ValueField プロパティのページの著作権

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

©2026 GRAS Group, Inc.RSS