TemplateContainerAttribute.BindingDirection Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mendapatkan arah pengikatan kontrol kontainer.
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
Nilai Properti
Menunjukkan BindingDirection arah pengikatan kontrol kontainer. Default adalah OneWay.
Contoh
Contoh kode berikut menunjukkan cara membuat kontrol templat bernama TemplatedFirstControl
dan mengaitkannya dengan kontainer bernama FirstTemplateContainer
. Ini memungkinkan pembuatan kontrol kustom yang menampilkan waktu server ketika templat tidak ditentukan dan konten templat saat templat ditentukan. Metode GetCustomAttribute menentukan BindingDirection properti properti FirstTemplate
dari TemplateFirstControl
.
Contoh kode ini adalah bagian dari contoh yang lebih besar yang disediakan untuk TemplateContainerAttribute kelas .
// 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
Keterangan
Properti BindingDirection dapat berupa OneWay bidang , di mana templat hanya dapat menerima nilai properti atau TwoWay bidang , di mana templat dapat menerima dan mengekspos nilai properti. Dalam skenario terakhir, kontrol terikat data secara otomatis dapat menggunakan operasi pembaruan, penghapusan, dan penyisipan sumber data menggunakan Bind
sintaks pengikatan data.
Untuk informasi selengkapnya tentang pengikatan data, lihat Ikatan ke Database dan Gambaran Umum Ekspresi Pengikatan Data.