TemplateContainerAttribute.BindingDirection Tulajdonság
Definíció
Fontos
Egyes információk olyan, kiadás előtti termékekre vonatkoznak, amelyek a kiadásig még jelentősen módosulhatnak. A Microsoft nem vállal kifejezett vagy törvényi garanciát az itt megjelenő információért.
Lekéri a tárolóvezérlő kötési irányát.
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
Tulajdonság értéke
A BindingDirection tárolóvezérlő kötési irányát jelző beállítás. Az alapértelmezett érték a OneWay.
Példák
Az alábbi példakód bemutatja, hogyan hozható létre egy sablonalapú vezérlő neve TemplatedFirstControl , és hogyan társítható egy nevesített FirstTemplateContainertárolóval. Ez lehetővé teszi olyan egyéni vezérlők létrehozását, amelyek megjelenítik a kiszolgáló idejét, amikor a sablon nincs megadva, valamint a sablon tartalmát a sablon megadásakor. A GetCustomAttribute metódus határozza meg a BindingDirection tulajdonság tulajdonságát FirstTemplateTemplateFirstControl.
Ez a példakód egy nagyobb, az TemplateContainerAttribute osztályhoz tartozó példa része.
// 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
Megjegyzések
A BindingDirection tulajdonság lehet az a OneWay mező, ahol a sablon csak a tulajdonságértékeket fogadja el, vagy a mezőt, ahol a sablon elfogadhatja és közzéteheti a TwoWay tulajdonságértékeket. Az utóbbi esetben az adatkötési vezérlők automatikusan használhatják az adatforrás frissítési, törlési és beszúrási műveleteit az Bind adatkötési szintaxis használatával.
További információ az adatkötésről: Kötés adatbázisokhoz és Data-Binding kifejezések áttekintése.