DataBoundControlAdapter クラスとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > DataBoundControlAdapter クラスの意味・解説 

DataBoundControlAdapter クラス

メモ : このクラスは、.NET Framework version 2.0新しく追加されたものです。

アダプタ関連付けられている DataBoundControl オブジェクトの、特定のブラウザ要求対す動作カスタマイズます。

名前空間: System.Web.UI.WebControls.Adapters
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public Class DataBoundControlAdapter
    Inherits WebControlAdapter
Dim instance As DataBoundControlAdapter
public class DataBoundControlAdapter : WebControlAdapter
public ref class DataBoundControlAdapter :
 public WebControlAdapter
public class DataBoundControlAdapter extends
 WebControlAdapter
public class DataBoundControlAdapter extends
 WebControlAdapter
解説解説

DataBoundControl クラスから派生したコントロールは、データ ソースバインドされ、バインド先のデータ ソース内の項目を列挙することによって、そのコントロールユーザー インターフェイスまたは子コントロール階層生成しますDataBoundControl は、データ ソースバインドできるすべてのコントロール (DataGrid コントロールListBox コントロールなど) の共通特性を定義する抽象基本クラスです。詳細については、「DataBoundControl」を参照してください

DataBoundControlAdapter は、特定のブラウザまたはブラウザクラス対すDataBoundControl動作変更しますまた、一部機能では、フィルタとして機能します表示動作適応性多くは、HtmlTextWriter クラスから派生した特定のクラスカプセル化できます。したがって単一アダプタブラウザ クラス複数動作使用することができ、また、HtmlTextWriter クラス順応性持たせることによってコントロール アダプタ使用する必要がなくなるとも言えます。

.browser 定義ファイル<controlAdapter> というエントリが存在する場合、各コントロールは、これらのファイル通じて明示的にアダプタ対応付けられます。そのため、アダプタコントロール対応付け必要なルックアップ実行する場合DataBoundControlAdapter プロパティ対すすべてのアクセスには、.browser 定義ファイルから抽出された HttpBrowserCapabilities オブジェクト使用されます。

処理中に.NET Framework が、ブラウザ固有のコントロールメソッド対す呼び出し受け取りますコントロール アダプタ割り当てられている場合.NET Framework は、関連付けられているアダプタ メソッド呼び出します。詳細については、「ControlAdapter」を参照してください

M:System.Web.UI.WebControls.Adapters.DataBoundControlAdapter.PerformDataBinding(System.Collections.IEnumerable) メソッドは、列挙可能なコレクションを、関連付けられている DataBoundControlバインドます。Control プロパティは、DataBoundControl コントロールへの、厳密に指定されている参照返します

使用例使用例

2 つ派生コントロール作成および使用する例を次に示します

最初コード例は、Web ページ使用してMyDataBound コントロール、および DataView オブジェクト形式データ提供する ObjectDataSource のインスタンス宣言してます。

2 番目のコード例には、派生した MyDataBound クラスMyDataBoundAdapter クラス含まれています。

Imports System
Imports System.Data
Imports System.Web
Imports System.Web.UI
Imports System.Collections
Imports System.Security
Imports System.Security.Permissions

Namespace MyControls

    ' MyDataBound control is a simple read-only grid control.
    <AspNetHostingPermission(SecurityAction.Demand, _
        Level:=AspNetHostingPermissionLevel.Minimal)> _
    <AspNetHostingPermission(SecurityAction.InheritanceDemand, _
        Level:=AspNetHostingPermissionLevel.Minimal)> _
    Public Class MyDataBound
        Inherits System.Web.UI.WebControls.DataBoundControl

        ' This is an enumerator for the data source.
        Private dataSourceEnumerator As IEnumerator
 = Nothing

        ' Render the data source as a table, without row and column
 headers.
        Protected Overrides Sub
 RenderContents( _
            ByVal writer As System.Web.UI.HtmlTextWriter)

            ' Render the <table> tag.
            writer.RenderBeginTag(HtmlTextWriterTag.Table)

            ' Render the table rows.
            While dataSourceEnumerator.MoveNext()

                ' Get the next data row as an object array.
                Dim dataArray As Object()
 = CType( _
                    dataSourceEnumerator.Current, DataRowView).Row.ItemArray

                ' Render the <tr> tag.
                writer.RenderBeginTag(HtmlTextWriterTag.Tr)

                ' Render the fields of the row.
                Dim col As Integer
                For col = 0 To (dataArray.GetLength(0))
 - 1

                    'Render the <td> tag, the field data and the
 </td> tag.
                    writer.RenderBeginTag(HtmlTextWriterTag.Td)
                    writer.Write(dataArray(col))
                    writer.RenderEndTag()
                Next col

                ' Render the </tr> tag.
                writer.RenderEndTag()
            End While

            ' Render the </table> tag.
            writer.RenderEndTag()
        End Sub 'RenderContents

        ' Data binding consists of saving an enumerator for the data.
        Protected Overrides Sub
 PerformDataBinding(ByVal data As IEnumerable)

            dataSourceEnumerator = data.GetEnumerator()
        End Sub 'PerformDataBinding
    End Class 'MyDataBound

    ' MyDataBoundAdapter modifies a MyDataBound control to display a
    ' grid as a list with row separators.
    <AspNetHostingPermission(SecurityAction.Demand, _
        Level:=AspNetHostingPermissionLevel.Minimal)> _
    <AspNetHostingPermission(SecurityAction.InheritanceDemand, _
        Level:=AspNetHostingPermissionLevel.Minimal)> _
    Public Class MyDataBoundAdapter
        Inherits System.Web.UI.WebControls.Adapters.DataBoundControlAdapter

        ' Returns a strongly-typed reference to the MyDataBound control.
        Public Shadows ReadOnly
 Property Control() As MyDataBound
            Get
                Return CType(MyBase.Control,
 MyDataBound)
            End Get
        End Property

        ' One-dimensional list for the grid data.
        Private dataArray As New
 ArrayList()

        ' Copy grid data to one-dimensional list, add row separators.
        Protected Overrides Sub
 PerformDataBinding(ByVal data As IEnumerable)

            Dim dataSourceEnumerator As IEnumerator
 = data.GetEnumerator()

            ' Iterate through the table rows.
            While dataSourceEnumerator.MoveNext()

                ' Add the next data row to the ArrayList.
                dataArray.AddRange(CType(dataSourceEnumerator.Current, _
                                        DataRowView).Row.ItemArray)

                ' Add a separator to the ArrayList.
                dataArray.Add("----------")
            End While
        End Sub 'PerformDataBinding

        ' Render the data source as a one-dimensional list.
        Protected Overrides Sub
 RenderContents( _
            ByVal writer As System.Web.UI.HtmlTextWriter)

            ' Render the data list.
            Dim col As Integer
            For col = 0 To dataArray.Count
 - 1
                writer.Write(dataArray(col))
                writer.WriteBreak()
            Next col
        End Sub 'RenderContents
    End Class 'MyDataBoundAdapter
 
End Namespace ' MyControls
using System;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Collections;
using System.Security.Permissions;

namespace MyControls
{
    // MyDataBound control is a simple read-only grid control.
    [AspNetHostingPermission(SecurityAction.Demand,
        Level = AspNetHostingPermissionLevel.Minimal)]
    [AspNetHostingPermission(SecurityAction.InheritanceDemand,
        Level = AspNetHostingPermissionLevel.Minimal)]
    public class MyDataBound : System.Web.UI.WebControls.DataBoundControl
    {
        // This is an enumerator for the data source.
        IEnumerator dataSourceEnumerator = null;

        // Render the data source as a table, without row and column
 headers.
        protected override void RenderContents(
            System.Web.UI.HtmlTextWriter writer)
        {
            // Render the <table> tag.
            writer.RenderBeginTag(HtmlTextWriterTag.Table);

            // Render the table rows.
            while (dataSourceEnumerator.MoveNext())
            {
                // Get the next data row as an object array.
                object[] dataArray = 
                    ((DataRowView)dataSourceEnumerator.Current).Row.ItemArray;

                // Render the <tr> tag.
                writer.RenderBeginTag(HtmlTextWriterTag.Tr);

                // Render the fields of the row.
                for(int col = 0; col<dataArray.GetLength(0)
 ; col++)
                {
                    //Render the <td> tag, the field data and
 the </td> tag.
                    writer.RenderBeginTag(HtmlTextWriterTag.Td);
                    writer.Write(dataArray[col]);
                    writer.RenderEndTag();
                }
                // Render the </tr> tag.
                writer.RenderEndTag();
            }
            // Render the </table> tag.
            writer.RenderEndTag();
        }

        // Data binding consists of saving an enumerator for the data.
        protected override void PerformDataBinding(IEnumerable
 data)
        {
            dataSourceEnumerator = data.GetEnumerator();
        }
    }

    // MyDataBoundAdapter modifies a MyDataBound control to display
 a
    // grid as a list with row separators.
    [AspNetHostingPermission(SecurityAction.Demand,
        Level = AspNetHostingPermissionLevel.Minimal)]
    [AspNetHostingPermission(SecurityAction.InheritanceDemand,
        Level = AspNetHostingPermissionLevel.Minimal)]
    public class MyDataBoundAdapter :
        System.Web.UI.WebControls.Adapters.DataBoundControlAdapter
    {
        // Returns a strongly-typed reference to the MyDataBound control.
        public new MyDataBound Control
        {
            get
            {
                return (MyDataBound)base.Control;
            }
        }

        // One-dimensional list for the grid data.
        ArrayList dataArray = new ArrayList();

        // Copy grid data to one-dimensional list, add row separators.
        protected override void PerformDataBinding(IEnumerable
 data)
        {
            IEnumerator dataSourceEnumerator = data.GetEnumerator();

            // Iterate through the table rows.
            while (dataSourceEnumerator.MoveNext())
            {
                // Add the next data row to the ArrayList.
                dataArray.AddRange(
                    ((DataRowView)dataSourceEnumerator.Current).Row.ItemArray);

                // Add a separator to the ArrayList.
                dataArray.Add("----------");
            }
        }

        // Render the data source as a one-dimensional list.
        protected override void RenderContents(
            System.Web.UI.HtmlTextWriter writer)
        {
            // Render the data list.
            for( int col=0; col<dataArray.Count;col++)
            {
                writer.Write(dataArray[col]);
                writer.WriteBreak();
            }
        }
    }
}

3 番目のコード例では、構成ファイル使用してMicrosoft Internet Explorer ブラウザ用の MyDataBound コントロールにはコントロール アダプタ使用せずOpenwave UP ブラウザ用の MyDataBound コントロールには MyDataBoundAdapter使用するように指定してます。

.NET Framework のセキュリティ.NET Frameworkセキュリティ
継承階層継承階層
System.Object
   System.Web.UI.Adapters.ControlAdapter
     System.Web.UI.WebControls.Adapters.WebControlAdapter
      System.Web.UI.WebControls.Adapters.DataBoundControlAdapter
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataBoundControlAdapter メンバ
System.Web.UI.WebControls.Adapters 名前空間
DataBoundControl クラス
BaseDataBoundControl クラス
WebControl クラス
ControlAdapter
WebControlAdapter
System.Web.UI.Control



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「DataBoundControlAdapter クラス」の関連用語

DataBoundControlAdapter クラスのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



DataBoundControlAdapter クラスのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS