TemplateContainerAttribute.BindingDirection プロパティ

定義

コンテナー コントロールのバインディング方向を取得します。

public:
 property System::ComponentModel::BindingDirection BindingDirection { System::ComponentModel::BindingDirection get(); };
public System.ComponentModel.BindingDirection BindingDirection { get; }
member this.BindingDirection : System.ComponentModel.BindingDirection
Public ReadOnly Property BindingDirection As BindingDirection

プロパティ値

BindingDirection

コンテナー コントロールのバインディング方向を示す BindingDirection。 既定値は、OneWay です。

次のコード例は、テンプレート化されたコントロールを作成し、それを名前付 TemplatedFirstControl きのコンテナー FirstTemplateContainerに関連付ける方法を示しています。 これにより、テンプレートが指定されていないサーバー時刻と、テンプレートが指定されたときにテンプレートの内容を表示するカスタム コントロールを作成できます。 メソッドは GetCustomAttributeBindingDirection のプロパティのプロパティを FirstTemplate 決定します TemplateFirstControl

このコード例は、TemplateContainerAttribute クラスのために提供されている大規模な例の一部です。

// Get the class type for which to access metadata.
Type clsType = typeof(TemplatedFirstControl);
// Get the PropertyInfo object for FirstTemplate.
PropertyInfo pInfo = clsType.GetProperty("FirstTemplate");
// See if the TemplateContainer attribute is defined for this property.
bool isDef = Attribute.IsDefined(pInfo, typeof(TemplateContainerAttribute));
// Display the result if the attribute exists.
if (isDef)
{
  TemplateContainerAttribute tca =
    (TemplateContainerAttribute)Attribute.GetCustomAttribute(pInfo, typeof(TemplateContainerAttribute));
  Response.Write("The binding direction is: " + tca.BindingDirection.ToString());
}
' Get the class type for which to access metadata.
Dim clsType As Type = GetType(VB_TemplatedFirstControl)
' Get the PropertyInfo object for FirstTemplate.
Dim pInfo As PropertyInfo = clsType.GetProperty("FirstTemplate")
' See if the TemplateContainer attribute is defined for this property.
Dim isDef As Boolean = Attribute.IsDefined(pInfo, GetType(TemplateContainerAttribute))
' Display the result if the attribute exists.
If isDef Then
  Dim tca As TemplateContainerAttribute = CType(Attribute.GetCustomAttribute(pInfo, GetType(TemplateContainerAttribute)), TemplateContainerAttribute)
  Response.Write("The binding direction is: " & tca.BindingDirection.ToString())
End If

注釈

プロパティは BindingDirection 、テンプレートが OneWay プロパティ値のみを受け入れることができるフィールドか、またはテンプレートがプロパティ値を TwoWay 受け入れて公開できるフィールドのいずれかです。 後者のシナリオでは、データ バインド コントロールは、データ バインディング構文を使用して、データ ソースの更新、削除、挿入操作を自動的に Bind 使用できます。

データ バインディングの詳細については、「 データベースへのバインドデータ バインディング式の概要」を参照してください。

適用対象

こちらもご覧ください