संपादित करें

इसके माध्यम से साझा किया गया


TemplateContainerAttribute.BindingDirection Property

Definition

Gets the binding direction of the container control.

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

Property Value

A BindingDirection indicating the container control's binding direction. The default is OneWay.

Examples

The following code example demonstrates how to create a templated control named TemplatedFirstControl and associate it with a container named FirstTemplateContainer. This allows the creation of custom controls that display the server time when the template is not specified and the contents of the template when the template is specified. The GetCustomAttribute method determines the BindingDirection property of the FirstTemplate property of the TemplateFirstControl.

This code example is part of a larger example provided for the TemplateContainerAttribute class.

// 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

Remarks

The BindingDirection property can be either the OneWay field, where the template can accept only property values or the TwoWay field, where the template can accept and expose property values. In the latter scenario, data-bound controls automatically can use the update, delete, and insert operations of a data source using the Bind data-binding syntax.

For more information on data binding, see Binding to Databases and Data-Binding Expressions Overview.

Applies to

See also