ListControlDataBindingHandler Kelas
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.
Melakukan pengikatan ListControl data kontrol server Web dalam perancang visual.
public ref class ListControlDataBindingHandler : System::Web::UI::Design::DataBindingHandler
public class ListControlDataBindingHandler : System.Web.UI.Design.DataBindingHandler
type ListControlDataBindingHandler = class
inherit DataBindingHandler
Public Class ListControlDataBindingHandler
Inherits DataBindingHandler
- Warisan
Contoh
Bagian ini berisi dua contoh kode. Yang pertama menunjukkan cara mendapatkan kontrol dari RadioButtonList kontrol dan mengaitkannya dengan penangan pengikatan datanya. Yang kedua menunjukkan cara memperoleh kelas dari ListControlDataBindingHandler kelas .
Contoh kode berikut menunjukkan cara mendapatkan SimpleRadioButtonList
kontrol dari RadioButtonList kontrol, lalu menerapkan DataBindingHandlerAttribute atribut untuk mengaitkan SimpleRadioButtonList
kontrol dengan handler pengikatan datanya, SimpleRadioButtonListDataBindingHandler
kelas .
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Security.Permissions;
namespace Examples.CS.WebControls.Design
{
// The SimpleRadioButtonList is a copy of the RadioButtonList.
// It uses the SimpleRadioButtonListDesigner for design-time support.
[AspNetHostingPermission(SecurityAction.Demand,
Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermission(SecurityAction.InheritanceDemand,
Level = AspNetHostingPermissionLevel.Minimal)]
[Designer(typeof(Examples.CS.WebControls.Design.
SimpleRadioButtonListDesigner))]
[DataBindingHandler(typeof(Examples.CS.WebControls.Design.
SimpleRadioButtonListDataBindingHandler))]
public class SimpleRadioButtonList : RadioButtonList
{
} // SimpleRadioButtonList
} // Examples.CS.WebControls.Design
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.ComponentModel
Imports System.Security.Permissions
Namespace Examples.VB.WebControls.Design
' The SimpleRadioButtonList is a copy of the RadioButtonList.
' It uses the SimpleRadioButtonListDesigner for design-time support.
<AspNetHostingPermission(SecurityAction.Demand, _
Level:=AspNetHostingPermissionLevel.Minimal)> _
<AspNetHostingPermission(SecurityAction.InheritanceDemand, _
Level:=AspNetHostingPermissionLevel.Minimal)> _
<DesignerAttribute(GetType(Examples.VB.WebControls.Design. _
SimpleRadioButtonListDesigner))> _
<DataBindingHandler(GetType(Examples.VB.WebControls.Design. _
SimpleRadioButtonListDataBindingHandler))> _
Public Class SimpleRadioButtonList
Inherits RadioButtonList
End Class
End Namespace ' Examples.VB.WebControls.Design
Contoh kode berikut menunjukkan cara mendapatkan SimpleRadioButtonListDataBindingHandler
kelas dari ListControlDataBindingHandler kelas . Ini mengambil alih DataBindControl metode untuk menambahkan pesan ke kontrol terkait SimpleRadioButtonList
ketika kontrol tersebut terikat data.
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Web.UI;
using System.Web.UI.Design.WebControls;
namespace Examples.CS.WebControls.Design
{
// Derive the SimpleRadioButtonListDataBindingHandler.
public class SimpleRadioButtonListDataBindingHandler :
ListControlDataBindingHandler
{
// Override the DataBindControl.
public override void DataBindControl(IDesignerHost designerHost,
Control control)
{
// Create a reference, named dataSourceBinding,
// to the control DataSource binding.
DataBinding dataSourceBinding =
((IDataBindingsAccessor)control).DataBindings["DataSource"];
// If the binding exists, create a reference to the
// list control, clear its ListItemCollection, and then add
// an item to the collection.
if (! (dataSourceBinding == null))
{
SimpleRadioButtonList simpleControl =
(SimpleRadioButtonList)control;
simpleControl.Items.Clear();
simpleControl.Items.Add("Data-bound Radio Button.");
}
} // DataBindControl
} // SimpleRadioButtonListDataBindingHandler
} // Examples.CS.WebControls.Design
' Imports System.Design
Imports System.ComponentModel
Imports System.ComponentModel.Design
Imports System.Web.UI
Imports System.Web.UI.Design.WebControls
Namespace Examples.VB.WebControls.Design
' Derive the SimpleRadioButtonListDataBindingHandler.
Public Class SimpleRadioButtonListDataBindingHandler
Inherits ListControlDataBindingHandler
' Override the DataBindControl.
Public Overrides Sub DataBindControl( _
ByVal designerHost As IDesignerHost, _
ByVal control As Control)
' Create a reference, named dataSourceBinding,
' to the control's DataSource binding.
Dim dataSourceBinding As DataBinding _
= CType( _
control, _
IDataBindingsAccessor).DataBindings("DataSource")
' If the binding exists, create a reference to the
' list control, clear its ListItemCollection, and then add
' an item to the collection.
If Not (dataSourceBinding Is Nothing) Then
Dim simpleControl As SimpleRadioButtonList = _
CType(control, SimpleRadioButtonList)
simpleControl.Items.Clear()
simpleControl.Items.Add("Data-bound Radio Button.")
End If
End Sub
End Class
End Namespace ' Examples.VB.WebControls.Design
Keterangan
Kelas ListControlDataBindingHandler melakukan pengikatan ListControl data waktu desain kontrol. Kelas ListControlDataBindingHandler dirujuk oleh ListControl menggunakan DataBindingHandlerAttribute kelas .
Metode ini DataBindControl melakukan pengikatan data waktu desain.
Konstruktor
ListControlDataBindingHandler() |
Menginisialisasi instans baru kelas ListControlDataBindingHandler. |
Metode
DataBindControl(IDesignerHost, Control) |
Melakukan pengikatan data pada kontrol yang ditentukan. |
Equals(Object) |
Menentukan apakah objek yang ditentukan sama dengan objek saat ini. (Diperoleh dari Object) |
GetHashCode() |
Berfungsi sebagai fungsi hash default. (Diperoleh dari Object) |
GetType() |
Mendapatkan dari instans Type saat ini. (Diperoleh dari Object) |
MemberwiseClone() |
Membuat salinan dangkal dari saat ini Object. (Diperoleh dari Object) |
ToString() |
Mengembalikan string yang mewakili objek saat ini. (Diperoleh dari Object) |
Berlaku untuk
Lihat juga
Saran dan Komentar
https://aka.ms/ContentUserFeedback.
Segera hadir: Sepanjang tahun 2024 kami akan menghentikan penggunaan GitHub Issues sebagai mekanisme umpan balik untuk konten dan menggantinya dengan sistem umpan balik baru. Untuk mengetahui informasi selengkapnya, lihat:Kirim dan lihat umpan balik untuk