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

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

CompositeDataBoundControl クラス

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

他の複数サーバー コントロール構成される形式データ バインド コントロール基本クラス表します

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

Public MustInherit Class
 CompositeDataBoundControl
    Inherits DataBoundControl
    Implements INamingContainer
Dim instance As CompositeDataBoundControl
public abstract class CompositeDataBoundControl
 : DataBoundControl, INamingContainer
public ref class CompositeDataBoundControl
 abstract : public DataBoundControl, INamingContainer
public abstract class CompositeDataBoundControl
 extends DataBoundControl implements INamingContainer
public abstract class CompositeDataBoundControl
 extends DataBoundControl implements INamingContainer
解説解説
使用例使用例

データ ソースの値をテーブル表示するカスタム複合データ バインド コントロール作成する方法次のコード例示します

Imports System
Imports System.Collections
Imports System.Data.Common
Imports System.Web.UI
Imports System.Web.UI.WebControls

Namespace Samples.AspNet.VB

    Public Class SimpleSpreadsheetControl
        Inherits CompositeDataBoundControl

        Protected table As New
 Table()

        Public Overridable ReadOnly
 Property Rows() As TableRowCollection
            Get
                Return table.Rows
            End Get
        End Property


        Protected Overrides Function
 CreateChildControls(ByVal dataSource As IEnumerable,
 ByVal dataBinding As Boolean) As Integer

            Dim count As Integer
 = 0
            ' If dataSource is not Nothing, iterate through it and
            ' extract each element from it as a row, then
            ' create a SimpleSpreadsheetRow and add it to the
            ' rows collection.
            If Not (dataSource Is
 Nothing) Then

                Dim row As SimpleSpreadsheetRow
                Dim e As IEnumerator = dataSource.GetEnumerator()

                While e.MoveNext()
                    Dim datarow As Object
 = e.Current
                    row = New SimpleSpreadsheetRow(count, datarow)
                    Me.Rows.Add(row)
                    count += 1
                End While

                Controls.Add(table)
            End If
            Return count
        End Function 'CreateChildControls
    End Class 'SimpleSpreadsheetControl


    Public Class SimpleSpreadsheetRow
        Inherits TableRow
        Implements IDataItemContainer

        Private dataObj As Object
        Private _itemIndex As Integer

        Public Sub New(ByVal
 itemIndex As Integer, ByVal
 o As Object)
            dataObj = o
            _itemIndex = itemIndex
        End Sub 'New

        Public Overridable ReadOnly
 Property Data() As Object
            Get
                Return dataObj
            End Get
        End Property

        ReadOnly Property DataItem() As
 Object Implements IDataItemContainer.DataItem
            Get
                Return Data
            End Get
        End Property

        ReadOnly Property DataItemIndex() As
 Integer Implements IDataItemContainer.DataItemIndex
            Get
                Return _itemIndex
            End Get
        End Property

        ReadOnly Property DisplayIndex() As
 Integer Implements IDataItemContainer.DisplayIndex
            Get
                Return _itemIndex
            End Get
        End Property
        Protected Overrides Sub
 RenderContents(ByVal writer As HtmlTextWriter)

            If Not (Data Is
 Nothing) Then
                If TypeOf Data Is
 System.Data.Common.DbDataRecord Then
                    Dim temp As DbDataRecord
 = CType(Data, DbDataRecord)
                    Dim i As Integer

                    While i < temp.FieldCount
                        writer.Write("<TD>")
                        writer.Write(temp.GetValue(i).ToString())
                        writer.Write("</TD>")
                        i += 1
                    End While
                Else
                    writer.Write(("<TD>" + Data.ToString()
 + "</TD>"))
                End If

            Else
                writer.Write("<TD>This is a test</TD>")
            End If
        End Sub 'RenderContents
    End Class 'SimpleSpreadsheetRow
End Namespace
using System;
using System.Collections;
using System.Data.Common;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Samples.AspNet.CS
{
    public class SimpleSpreadsheetControl :
 CompositeDataBoundControl
    {
        protected Table table = new Table();

        public virtual TableRowCollection Rows
        {
            get
            {
                return table.Rows;
            }
        }

        protected override int CreateChildControls(IEnumerable
 dataSource, bool dataBinding)
        {

            int count = 0;
            // If dataSource is not null, iterate through it and
            // extract each element from it as a row, then
            // create a SimpleSpreadsheetRow and add it to the
            // rows collection.
            if (dataSource != null)
            {

                SimpleSpreadsheetRow row;
                IEnumerator e = dataSource.GetEnumerator();

                while (e.MoveNext())
                {
                    object datarow = e.Current;
                    row = new SimpleSpreadsheetRow(count, datarow);
                    this.Rows.Add(row);
                    ++count;
                }

                Controls.Add(table);
            }
            return count;
        }
    }

    //
    //
    public class SimpleSpreadsheetRow : TableRow,
 IDataItemContainer
    {
        private object data;
        private int _itemIndex;

        public SimpleSpreadsheetRow(int itemIndex,
 object o)
        {
            data = o;
            _itemIndex = itemIndex;
        }

        public virtual object Data
        {
            get
            {
                return data;
            }
        }
        object IDataItemContainer.DataItem
        {
            get
            {
                return Data;
            }
        }
        int IDataItemContainer.DataItemIndex
        {
            get
            {
                return _itemIndex;
            }
        }
        int IDataItemContainer.DisplayIndex
        {
            get
            {
                return _itemIndex;
            }
        }
        protected override void RenderContents(HtmlTextWriter
 writer)
        {

            if (Data != null)
            {
                if (Data is System.Data.Common.DbDataRecord)
                {
                    DbDataRecord temp = (DbDataRecord)Data;
                    for (int i = 0; i <
 temp.FieldCount; ++i)
                    {
                        writer.Write("<TD>");
                        writer.Write(temp.GetValue(i).ToString());
                        writer.Write("</TD>");
                    }
                }
                else
                    writer.Write("<TD>" + Data.ToString() + "</TD>");
            }

            else
                writer.Write("<TD>This is a test</TD>");
        }
    }
}
.NET Framework のセキュリティ.NET Frameworkセキュリティ
継承階層継承階層
System.Object
   System.Web.UI.Control
     System.Web.UI.WebControls.WebControl
       System.Web.UI.WebControls.BaseDataBoundControl
         System.Web.UI.WebControls.DataBoundControl
          System.Web.UI.WebControls.CompositeDataBoundControl
             System.Web.UI.WebControls.DetailsView
             System.Web.UI.WebControls.FormView
             System.Web.UI.WebControls.GridView
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバ場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
CompositeDataBoundControl メンバ
System.Web.UI.WebControls 名前空間
BaseDataBoundControl クラス
DataBoundControl
HierarchicalDataBoundControl
DetailsView
FormView
GridView
Controls



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

辞書ショートカット

すべての辞書の索引

「CompositeDataBoundControl クラス」の関連用語

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

   

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



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

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

©2025 GRAS Group, Inc.RSS