ListControlDataBindingHandler クラス

定義

ビジュアル デザイナー内で ListControl Web サーバー コントロールのデータ バインディングを実行します。

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
継承
ListControlDataBindingHandler

このセクションには、2 つのコード例が含まれています。 最初の方法は、コントロールからコントロールを派生させ、 RadioButtonList そのデータ バインディング ハンドラーに関連付ける方法を示しています。 2 つ目は、 クラスから クラスを派生させる方法を ListControlDataBindingHandler 示しています。

次のコード例は、コントロールからRadioButtonListコントロールをSimpleRadioButtonList派生させ、 属性をDataBindingHandlerAttribute適用してコントロールをデータ バインディング ハンドラーである クラスに関連付けるSimpleRadioButtonList方法をSimpleRadioButtonListDataBindingHandler示しています。

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

次のコード例は、 クラスから クラスを SimpleRadioButtonListDataBindingHandler 派生させる方法を ListControlDataBindingHandler 示しています。 メソッドを DataBindControl オーバーライドして、そのコントロールがデータ バインドされている場合に、関連付けられた SimpleRadioButtonList コントロールにメッセージを追加します。

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

注釈

クラスは ListControlDataBindingHandler 、コントロールのデザイン時データ バインディングを ListControl 実行します。 クラスは ListControlDataBindingHandler 、 クラスを ListControl 使用して DataBindingHandlerAttribute によって参照されます。

メソッドは DataBindControl 、デザイン時のデータ バインディングを実行します。

コンストラクター

ListControlDataBindingHandler()

ListControlDataBindingHandler クラスの新しいインスタンスを初期化します。

メソッド

DataBindControl(IDesignerHost, Control)

指定したコントロールでのデータ連結を実行します。

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

適用対象

こちらもご覧ください