data source controlとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework用語 > data source controlの意味・解説 

データ ソース コントロール [data source control]


DataSourceControl イベント


DataSourceControl クラス

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

データ バインド コントロールに対してデータ ソースを表すコントロールの基本クラスとして機能します。

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

<BindableAttribute(False)> _
Public MustInherit Class
 DataSourceControl
    Inherits Control
    Implements IDataSource, IListSource
Dim instance As DataSourceControl
[BindableAttribute(false)] 
public abstract class DataSourceControl : Control,
 IDataSource, IListSource
[BindableAttribute(false)] 
public ref class DataSourceControl abstract
 : public Control, IDataSource, IListSource
/** @attribute BindableAttribute(false) */ 
public abstract class DataSourceControl extends
 Control implements IDataSource, IListSource
BindableAttribute(false) 
public abstract class DataSourceControl extends
 Control implements IDataSource, IListSource
解説解説

ASP.NET では、Web サーバー コントロールを一貫した方式でデータにバインドできるようにするコントロール データ バインディング アーキテクチャがサポートされています。データにバインドされる Web サーバー コントロールをデータ バインド コントロールといいます。また、そのバインディングを容易にするクラスをデータ ソース コントロールといいます。データ ソース コントロールは、リレーショナル データベース、ファイル、ストリーム、ビジネス オブジェクトなど、あらゆるデータ ソースを表すことができます。データ ソース コントロールにより、基になるデータのソースや形式にかかわらず、一貫した方式でデータがデータ バインド コントロールに提供されます。

多くの Web 開発タスクは、ASP.NET に用意されている SqlDataSource、AccessDataSource、XmlDataSource などのデータ ソース コントロールを使用して行います。独自のカスタム データ ソース コントロールを実装する場合は、DataSourceControl 基本クラスを使用します。

IDataSource インターフェイスを実装するクラスはすべてデータ ソース コントロールですが、ほとんどの ASP.NET データ ソース コントロールは、IDataSource インターフェイスの基本の実装を提供する DataSourceControl 抽象クラスを拡張します。また、DataSourceControl クラスは、IListSource インターフェイスの実装も提供します。これにより、プログラムを使用して、データ バインド コントロールの DataSource プロパティにデータ ソース コントロールを割り当て、データを基本リストとしてコントロールに返すことができます。

DataBoundControl クラスから派生するすべての ASP.NET コントロールは、データ ソース コントロールにバインドできます。DataBoundControl をデータ ソース コントロールにバインドすると、実行時に、データ バインディングが自動的に実行されます。また、DataSource プロパティまたは DataSourceID プロパティを公開し基本的なデータ バインディングをサポートするが DataBoundControl から派生していないような ASP.NET コントロールでも、データ ソース コントロールを使用できます。このようなデータ バインド コントロールを使用する場合、DataBind メソッドを明示的に呼び出す必要があります。データ バインディングの詳細については、「ASP.NET でのデータ アクセス」を参照してください。

データ ソース コントロールは、DataSourceControl オブジェクトに、そのオブジェクトに関連付けられたデータ ソース ビューと呼ばれるリストを組み合わせたものと考えることができます。データの各リストは、DataSourceView オブジェクトで表されます。基になるデータ ストレージには 1 つ以上のデータのリストが含まれているので、DataSourceControl は、1 つ以上の名前付きの DataSourceView オブジェクトに常に関連付けられています。IDataSource インターフェイスは、すべてのデータ ソース コントロールがデータ ソース ビューとの対話に使用するメソッドを定義します。GetViewNames メソッドは、現在データ ソース コントロールに関連付けられているデータ ソース ビューを列挙する場合に使用し、GetView メソッドは、特定のデータ ソース ビューのインスタンスを名前で取得する場合に使用します。

また、データ ソース コントロールは、呼び出し元がデータにアクセスする際に使用する異なる 2 つのインターフェイスと見なすこともできます。DataSourceControl クラスは、ページの開発者が Web フォーム ページを作成する場合に直接対話するインターフェイスです。また、DataSourceView クラスは、データ バインド コントロールとデータ バインド コントロールの作成者が対話するインターフェイスです。DataSourceView オブジェクトを使用できるのは実行時だけなので、データ ソース コントロールまたはデータ ソース ビューに保持された状態は、データ ソース コントロールで直接公開する必要があります。

ASP.NET データ ソース コントロールは視覚的に表示されません。そのため、これらを宣言を使用して作成できるようにコントロールとして実装し、オプションで、状態管理に関与させることができます。結果として、データ ソース コントロールでは、EnableTheming や SkinID などの表示機能がサポートされません。

使用例使用例

あるクラスで DataSourceControl クラスを拡張する方法を次のコード例に示します。CsvDataSource コントロールは、.csv ファイルに格納されたコンマ区切りのファイル データを表します。基本クラスの実装は機能しないため、CsvDataSource クラスで、GetView、GetViewNames、およびその他のメソッドの独自の実装を提供します。

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

Namespace Samples.AspNet.VB.Controls

' The CsvDataSource is a data source control that retrieves its
' data from a comma-separated value file.
<AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Minimal)>
 _
Public Class CsvDataSource
   Inherits DataSourceControl

   Public Sub New()
   End Sub 'New

   ' The comma-separated value file to retrieve data from.
   Public Property FileName() As
 String
      Get
         Return CType(Me.GetView([String].Empty),
 CsvDataSourceView).SourceFile
      End Get
      Set
         ' Only set if it is different.
         If CType(Me.GetView([String].Empty),
 CsvDataSourceView).SourceFile <> value Then
            CType(Me.GetView([String].Empty), CsvDataSourceView).SourceFile
 = value
            RaiseDataSourceChangedEvent(EventArgs.Empty)
         End If
      End Set
   End Property

   ' Do not add the column names as a data row. Infer columns if the
 CSV file does
   ' not include column names.

   Public Property IncludesColumnNames() As
 Boolean
      Get
         Return CType(Me.GetView([String].Empty),
 CsvDataSourceView).IncludesColumnNames
      End Get
      Set
         ' Only set if it is different.
         If CType(Me.GetView([String].Empty),
 CsvDataSourceView).IncludesColumnNames <> value Then
            CType(Me.GetView([String].Empty), CsvDataSourceView).IncludesColumnNames
 = value
            RaiseDataSourceChangedEvent(EventArgs.Empty)
         End If
      End Set
   End Property


   ' Return a strongly typed view for the current data source control.
   Private view As CsvDataSourceView = Nothing

   Protected Overrides Function
 GetView(viewName As String) As
 DataSourceView
      If view Is Nothing
 Then
         view = New CsvDataSourceView(Me, String.Empty)
      End If
      Return view
   End Function 'GetView

   ' The ListSourceHelper class calls GetList, which
   ' calls the DataSourceControl.GetViewNames method.
   ' Override the original implementation to return
   ' a collection of one element, the default view name.
   Protected Overrides Function
 GetViewNames() As ICollection
      Dim al As New ArrayList(1)
      al.Add(CsvDataSourceView.DefaultViewName)
      Return CType(al, ICollection)
   End Function 'GetViewNames

End Class 'CsvDataSource


' The CsvDataSourceView class encapsulates the
' capabilities of the CsvDataSource data source control.

Public Class CsvDataSourceView
   Inherits DataSourceView

   Public Sub New(owner
 As IDataSource, name As String)
       MyBase.New(owner, DefaultViewName)
   End Sub 'New

   ' The data source view is named. However, the CsvDataSource
   ' only supports one view, so the name is ignored, and the
   ' default name used instead.
   Public Shared DefaultViewName As
 String = "CommaSeparatedView"

   ' The location of the .csv file.
   Private aSourceFile As String
 = [String].Empty

   Friend Property SourceFile() As
 String
      Get
         Return aSourceFile
      End Get
      Set
         ' Use MapPath when the SourceFile is set, so that files local
 to the
         ' current directory can be easily used.
         Dim mappedFileName As String
         mappedFileName = HttpContext.Current.Server.MapPath(value)
         aSourceFile = mappedFileName
      End Set
   End Property

   ' Do not add the column names as a data row. Infer columns if the
 CSV file does
   ' not include column names.
   Private columns As Boolean
 = False

   Friend Property IncludesColumnNames() As
 Boolean
      Get
         Return columns
      End Get
      Set
         columns = value
      End Set
   End Property

   ' Get data from the underlying data source.
   ' Build and return a DataView, regardless of mode.
   Protected Overrides Function
 ExecuteSelect(selectArgs As DataSourceSelectArguments) _
    As System.Collections.IEnumerable
      Dim dataList As IEnumerable = Nothing
      ' Open the .csv file.
      If File.Exists(Me.SourceFile) Then
         Dim data As New
 DataTable()

         ' Open the file to read from.
         Dim sr As StreamReader = File.OpenText(Me.SourceFile)

         Try
            ' Parse the line
            Dim dataValues() As String
            Dim col As DataColumn

            ' Do the following to add schema.
            dataValues = sr.ReadLine().Split(","c)
            ' For each token in the comma-delimited string, add a column
            ' to the DataTable schema.
            Dim token As String
            For Each token In
 dataValues
               col = New DataColumn(token, System.Type.GetType("System.String"))
               data.Columns.Add(col)
            Next token

            ' Do not add the first row as data if the CSV file includes
 column names.
            If Not IncludesColumnNames Then
               data.Rows.Add(CopyRowData(dataValues, data.NewRow()))
            End If

            ' Do the following to add data.
            Dim s As String
            Do
               s = sr.ReadLine()
               If Not s Is
 Nothing Then
                   dataValues = s.Split(","c)
                   data.Rows.Add(CopyRowData(dataValues, data.NewRow()))
               End If
            Loop Until s Is
 Nothing

         Finally
            sr.Close()
         End Try

         data.AcceptChanges()
         Dim dataView As New
 DataView(data)
         If Not selectArgs.SortExpression Is
 String.Empty Then
             dataView.Sort = selectArgs.SortExpression
         End If
         dataList = dataView
      Else
         Throw New System.Configuration.ConfigurationErrorsException("File
 not found, " + Me.SourceFile)
      End If

      If dataList is Nothing
 Then
         Throw New InvalidOperationException("No
 data loaded from data source.")
      End If

      Return dataList
   End Function 'ExecuteSelect


   Private Function CopyRowData([source]()
 As String, target As DataRow)
 As DataRow
      Try
         Dim i As Integer
         For i = 0 To [source].Length - 1
            target(i) = [source](i)
         Next i
      Catch iore As IndexOutOfRangeException
         ' There are more columns in this row than
         ' the original schema allows.  Stop copying
         ' and return the DataRow.
         Return target
      End Try
      Return target
   End Function 'CopyRowData

   ' The CsvDataSourceView does not currently
   ' permit deletion. You can modify or extend
   ' this sample to do so.
   Public Overrides ReadOnly
 Property CanDelete() As Boolean
      Get
         Return False
      End Get
   End Property

   Protected Overrides Function
 ExecuteDelete(keys As IDictionary, values As
 IDictionary) As Integer
      Throw New NotSupportedException()
   End Function 'ExecuteDelete

   ' The CsvDataSourceView does not currently
   ' permit insertion of a new record. You can
   ' modify or extend this sample to do so.
   Public Overrides ReadOnly
 Property CanInsert() As Boolean
      Get
         Return False
      End Get
   End Property

   Protected Overrides Function
 ExecuteInsert(values As IDictionary) As Integer
      Throw New NotSupportedException()
   End Function 'ExecuteInsert

   ' The CsvDataSourceView does not currently
   ' permit update operations. You can modify or
   ' extend this sample to do so.
   Public Overrides ReadOnly
 Property CanUpdate() As Boolean
      Get
         Return False
      End Get
   End Property

   Protected Overrides Function
 ExecuteUpdate(keys As IDictionary, _
                                              values As IDictionary,
 _
                                              oldValues As IDictionary)
 As Integer
      Throw New NotSupportedException()
   End Function 'ExecuteUpdate

End Class 'CsvDataSourceView
End Namespace
using System;
using System.Collections;
using System.Data;
using System.IO;
using System.Security.Permissions;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

// The CsvDataSource is a data source control that retrieves its
// data from a comma-separated value file.
[AspNetHostingPermission(SecurityAction.Demand, Level=AspNetHostingPermissionLevel.Minimal)]
public class CsvDataSource : DataSourceControl
{
    public CsvDataSource() : base() {}

    // The comma-separated value file to retrieve data from.
    public string FileName {
        get {
            return ((CsvDataSourceView)this.GetView(String.Empty)).SourceFile;
        }
        set {
            // Only set if it is different.
            if ( ((CsvDataSourceView)this.GetView(String.Empty)).SourceFile
 != value) {
                ((CsvDataSourceView)this.GetView(String.Empty)).SourceFile
 = value;
                RaiseDataSourceChangedEvent(EventArgs.Empty);
            }
        }
    }

    // Do not add the column names as a data row. Infer columns if the
 CSV file does
    // not include column names.
    public bool IncludesColumnNames {
        get {
            return ((CsvDataSourceView)this.GetView(String.Empty)).IncludesColumnNames;
        }
        set {
            // Only set if it is different.
            if ( ((CsvDataSourceView)this.GetView(String.Empty)).IncludesColumnNames
 != value) {
                ((CsvDataSourceView)this.GetView(String.Empty)).IncludesColumnNames
 = value;
                RaiseDataSourceChangedEvent(EventArgs.Empty);
            }
        }
    }

    // Return a strongly typed view for the current data source control.
    private CsvDataSourceView view = null;
    protected override DataSourceView GetView(string
 viewName) {
        if (null == view) {
            view = new CsvDataSourceView(this,
 String.Empty);
        }
        return view;
    }
    // The ListSourceHelper class calls GetList, which
    // calls the DataSourceControl.GetViewNames method.
    // Override the original implementation to return
    // a collection of one element, the default view name.
    protected override ICollection GetViewNames() {
        ArrayList al = new ArrayList(1);
        al.Add(CsvDataSourceView.DefaultViewName);
        return al as ICollection;
    }
}

// The CsvDataSourceView class encapsulates the
// capabilities of the CsvDataSource data source control.
public class CsvDataSourceView : DataSourceView
{

    public CsvDataSourceView(IDataSource owner, string
 name) :base(owner, DefaultViewName) {

    }

    // The data source view is named. However, the CsvDataSource
    // only supports one view, so the name is ignored, and the
    // default name used instead.
    public static string
 DefaultViewName = "CommaSeparatedView";

    // The location of the .csv file.
    private string sourceFile = String.Empty;
    internal string SourceFile {
        get {
            return sourceFile;
        }
        set {
            // Use MapPath when the SourceFile is set, so that files
 local to the
            // current directory can be easily used.
            string mappedFileName = HttpContext.Current.Server.MapPath(value);
            sourceFile = mappedFileName;
        }
    }

    // Do not add the column names as a data row. Infer columns if the
 CSV file does
    // not include column names.
    private bool columns = false;
    internal bool IncludesColumnNames {
        get {
            return columns;
        }
        set {
            columns = value;
        }
    }

    // Get data from the underlying data source.
    // Build and return a DataView, regardless of mode.
    protected override IEnumerable ExecuteSelect(DataSourceSelectArguments
 selectArgs) {
        IEnumerable dataList = null;
        // Open the .csv file.
        if (File.Exists(this.SourceFile)) {
            DataTable data = new DataTable();

            // Open the file to read from.
            using (StreamReader sr = File.OpenText(this.SourceFile))
 {
                // Parse the line
                string s = "";
                string[] dataValues;
                DataColumn col;

                // Do the following to add schema.
                dataValues = sr.ReadLine().Split(',');
                // For each token in the comma-delimited string, add
 a column
                // to the DataTable schema.
                foreach (string token in
 dataValues) {
                    col = new DataColumn(token,typeof(string));
                    data.Columns.Add(col);
                }

                // Do not add the first row as data if the CSV file
 includes column names.
                if (! IncludesColumnNames)
                    data.Rows.Add(CopyRowData(dataValues, data.NewRow()));

                // Do the following to add data.
                while ((s = sr.ReadLine()) != null)
 {
                    dataValues = s.Split(',');
                    data.Rows.Add(CopyRowData(dataValues, data.NewRow()));
                }
            }
            data.AcceptChanges();
            DataView dataView = new DataView(data);
            if (selectArgs.SortExpression != String.Empty) {
                dataView.Sort = selectArgs.SortExpression;
            }
            dataList = dataView;
        }
        else {
            throw new System.Configuration.ConfigurationErrorsException("File
 not found, " + this.SourceFile);
        }

        if (null == dataList) {
            throw new InvalidOperationException("No data
 loaded from data source.");
        }

        return dataList;
    }

    private DataRow CopyRowData(string[] source,
 DataRow target) {
        try {
            for (int i = 0;i < source.Length;i++)
 {
                target[i] = source[i];
            }
        }
        catch (System.IndexOutOfRangeException) {
            // There are more columns in this row than
            // the original schema allows.  Stop copying
            // and return the DataRow.
            return target;
        }
        return target;
    }
    // The CsvDataSourceView does not currently
    // permit deletion. You can modify or extend
    // this sample to do so.
    public override bool CanDelete {
        get {
            return false;
        }
    }
    protected override int ExecuteDelete(IDictionary
 keys, IDictionary values)
    {
        throw new NotSupportedException();
    }
    // The CsvDataSourceView does not currently
    // permit insertion of a new record. You can
    // modify or extend this sample to do so.
    public override bool CanInsert {
        get {
            return false;
        }
    }
    protected override int ExecuteInsert(IDictionary
 values)
    {
        throw new NotSupportedException();
    }
    // The CsvDataSourceView does not currently
    // permit update operations. You can modify or
    // extend this sample to do so.
    public override bool CanUpdate {
        get {
            return false;
        }
    }
    protected override int ExecuteUpdate(IDictionary
 keys, IDictionary values, IDictionary oldValues)
    {
        throw new NotSupportedException();
    }
}

Web フォームで CsvDataSource コントロールを使用する方法を次のコード例に示します。

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

Namespace Samples.AspNet.VB.Controls

' The CsvDataSource is a data source control that retrieves its
' data from a comma-separated value file.
<AspNetHostingPermission(SecurityAction.Demand, Level:=AspNetHostingPermissionLevel.Minimal)>
 _
Public Class CsvDataSource
   Inherits DataSourceControl

   Public Sub New()
   End Sub 'New

   ' The comma-separated value file to retrieve data from.
   Public Property FileName() As
 String
      Get
         Return CType(Me.GetView([String].Empty),
 CsvDataSourceView).SourceFile
      End Get
      Set
         ' Only set if it is different.
         If CType(Me.GetView([String].Empty),
 CsvDataSourceView).SourceFile <> value Then
            CType(Me.GetView([String].Empty), CsvDataSourceView).SourceFile
 = value
            RaiseDataSourceChangedEvent(EventArgs.Empty)
         End If
      End Set
   End Property

   ' Do not add the column names as a data row. Infer columns if the
 CSV file does
   ' not include column names.

   Public Property IncludesColumnNames() As
 Boolean
      Get
         Return CType(Me.GetView([String].Empty),
 CsvDataSourceView).IncludesColumnNames
      End Get
      Set
         ' Only set if it is different.
         If CType(Me.GetView([String].Empty),
 CsvDataSourceView).IncludesColumnNames <> value Then
            CType(Me.GetView([String].Empty), CsvDataSourceView).IncludesColumnNames
 = value
            RaiseDataSourceChangedEvent(EventArgs.Empty)
         End If
      End Set
   End Property


   ' Return a strongly typed view for the current data source control.
   Private view As CsvDataSourceView = Nothing

   Protected Overrides Function
 GetView(viewName As String) As
 DataSourceView
      If view Is Nothing
 Then
         view = New CsvDataSourceView(Me, String.Empty)
      End If
      Return view
   End Function 'GetView

   ' The ListSourceHelper class calls GetList, which
   ' calls the DataSourceControl.GetViewNames method.
   ' Override the original implementation to return
   ' a collection of one element, the default view name.
   Protected Overrides Function
 GetViewNames() As ICollection
      Dim al As New ArrayList(1)
      al.Add(CsvDataSourceView.DefaultViewName)
      Return CType(al, ICollection)
   End Function 'GetViewNames

End Class 'CsvDataSource


' The CsvDataSourceView class encapsulates the
' capabilities of the CsvDataSource data source control.

Public Class CsvDataSourceView
   Inherits DataSourceView

   Public Sub New(owner
 As IDataSource, name As String)
       MyBase.New(owner, DefaultViewName)
   End Sub 'New

   ' The data source view is named. However, the CsvDataSource
   ' only supports one view, so the name is ignored, and the
   ' default name used instead.
   Public Shared DefaultViewName As
 String = "CommaSeparatedView"

   ' The location of the .csv file.
   Private aSourceFile As String
 = [String].Empty

   Friend Property SourceFile() As
 String
      Get
         Return aSourceFile
      End Get
      Set
         ' Use MapPath when the SourceFile is set, so that files local
 to the
         ' current directory can be easily used.
         Dim mappedFileName As String
         mappedFileName = HttpContext.Current.Server.MapPath(value)
         aSourceFile = mappedFileName
      End Set
   End Property

   ' Do not add the column names as a data row. Infer columns if the
 CSV file does
   ' not include column names.
   Private columns As Boolean
 = False

   Friend Property IncludesColumnNames() As
 Boolean
      Get
         Return columns
      End Get
      Set
         columns = value
      End Set
   End Property

   ' Get data from the underlying data source.
   ' Build and return a DataView, regardless of mode.
   Protected Overrides Function
 ExecuteSelect(selectArgs As DataSourceSelectArguments) _
    As System.Collections.IEnumerable
      Dim dataList As IEnumerable = Nothing
      ' Open the .csv file.
      If File.Exists(Me.SourceFile) Then
         Dim data As New
 DataTable()

         ' Open the file to read from.
         Dim sr As StreamReader = File.OpenText(Me.SourceFile)

         Try
            ' Parse the line
            Dim dataValues() As String
            Dim col As DataColumn

            ' Do the following to add schema.
            dataValues = sr.ReadLine().Split(","c)
            ' For each token in the comma-delimited string, add a column
            ' to the DataTable schema.
            Dim token As String
            For Each token In
 dataValues
               col = New DataColumn(token, System.Type.GetType("System.String"))
               data.Columns.Add(col)
            Next token

            ' Do not add the first row as data if the CSV file includes
 column names.
            If Not IncludesColumnNames Then
               data.Rows.Add(CopyRowData(dataValues, data.NewRow()))
            End If

            ' Do the following to add data.
            Dim s As String
            Do
               s = sr.ReadLine()
               If Not s Is
 Nothing Then
                   dataValues = s.Split(","c)
                   data.Rows.Add(CopyRowData(dataValues, data.NewRow()))
               End If
            Loop Until s Is
 Nothing

         Finally
            sr.Close()
         End Try

         data.AcceptChanges()
         Dim dataView As New
 DataView(data)
         If Not selectArgs.SortExpression Is
 String.Empty Then
             dataView.Sort = selectArgs.SortExpression
         End If
         dataList = dataView
      Else
         Throw New System.Configuration.ConfigurationErrorsException("File
 not found, " + Me.SourceFile)
      End If

      If dataList is Nothing
 Then
         Throw New InvalidOperationException("No
 data loaded from data source.")
      End If

      Return dataList
   End Function 'ExecuteSelect


   Private Function CopyRowData([source]()
 As String, target As DataRow)
 As DataRow
      Try
         Dim i As Integer
         For i = 0 To [source].Length - 1
            target(i) = [source](i)
         Next i
      Catch iore As IndexOutOfRangeException
         ' There are more columns in this row than
         ' the original schema allows.  Stop copying
         ' and return the DataRow.
         Return target
      End Try
      Return target
   End Function 'CopyRowData

   ' The CsvDataSourceView does not currently
   ' permit deletion. You can modify or extend
   ' this sample to do so.
   Public Overrides ReadOnly
 Property CanDelete() As Boolean
      Get
         Return False
      End Get
   End Property

   Protected Overrides Function
 ExecuteDelete(keys As IDictionary, values As
 IDictionary) As Integer
      Throw New NotSupportedException()
   End Function 'ExecuteDelete

   ' The CsvDataSourceView does not currently
   ' permit insertion of a new record. You can
   ' modify or extend this sample to do so.
   Public Overrides ReadOnly
 Property CanInsert() As Boolean
      Get
         Return False
      End Get
   End Property

   Protected Overrides Function
 ExecuteInsert(values As IDictionary) As Integer
      Throw New NotSupportedException()
   End Function 'ExecuteInsert

   ' The CsvDataSourceView does not currently
   ' permit update operations. You can modify or
   ' extend this sample to do so.
   Public Overrides ReadOnly
 Property CanUpdate() As Boolean
      Get
         Return False
      End Get
   End Property

   Protected Overrides Function
 ExecuteUpdate(keys As IDictionary, _
                                              values As IDictionary,
 _
                                              oldValues As IDictionary)
 As Integer
      Throw New NotSupportedException()
   End Function 'ExecuteUpdate

End Class 'CsvDataSourceView
End Namespace
using System;
using System.Collections;
using System.Data;
using System.IO;
using System.Security.Permissions;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

// The CsvDataSource is a data source control that retrieves its
// data from a comma-separated value file.
[AspNetHostingPermission(SecurityAction.Demand, Level=AspNetHostingPermissionLevel.Minimal)]
public class CsvDataSource : DataSourceControl
{
    public CsvDataSource() : base() {}

    // The comma-separated value file to retrieve data from.
    public string FileName {
        get {
            return ((CsvDataSourceView)this.GetView(String.Empty)).SourceFile;
        }
        set {
            // Only set if it is different.
            if ( ((CsvDataSourceView)this.GetView(String.Empty)).SourceFile
 != value) {
                ((CsvDataSourceView)this.GetView(String.Empty)).SourceFile
 = value;
                RaiseDataSourceChangedEvent(EventArgs.Empty);
            }
        }
    }

    // Do not add the column names as a data row. Infer columns if the
 CSV file does
    // not include column names.
    public bool IncludesColumnNames {
        get {
            return ((CsvDataSourceView)this.GetView(String.Empty)).IncludesColumnNames;
        }
        set {
            // Only set if it is different.
            if ( ((CsvDataSourceView)this.GetView(String.Empty)).IncludesColumnNames
 != value) {
                ((CsvDataSourceView)this.GetView(String.Empty)).IncludesColumnNames
 = value;
                RaiseDataSourceChangedEvent(EventArgs.Empty);
            }
        }
    }

    // Return a strongly typed view for the current data source control.
    private CsvDataSourceView view = null;
    protected override DataSourceView GetView(string
 viewName) {
        if (null == view) {
            view = new CsvDataSourceView(this,
 String.Empty);
        }
        return view;
    }
    // The ListSourceHelper class calls GetList, which
    // calls the DataSourceControl.GetViewNames method.
    // Override the original implementation to return
    // a collection of one element, the default view name.
    protected override ICollection GetViewNames() {
        ArrayList al = new ArrayList(1);
        al.Add(CsvDataSourceView.DefaultViewName);
        return al as ICollection;
    }
}

// The CsvDataSourceView class encapsulates the
// capabilities of the CsvDataSource data source control.
public class CsvDataSourceView : DataSourceView
{

    public CsvDataSourceView(IDataSource owner, string
 name) :base(owner, DefaultViewName) {

    }

    // The data source view is named. However, the CsvDataSource
    // only supports one view, so the name is ignored, and the
    // default name used instead.
    public static string
 DefaultViewName = "CommaSeparatedView";

    // The location of the .csv file.
    private string sourceFile = String.Empty;
    internal string SourceFile {
        get {
            return sourceFile;
        }
        set {
            // Use MapPath when the SourceFile is set, so that files
 local to the
            // current directory can be easily used.
            string mappedFileName = HttpContext.Current.Server.MapPath(value);
            sourceFile = mappedFileName;
        }
    }

    // Do not add the column names as a data row. Infer columns if the
 CSV file does
    // not include column names.
    private bool columns = false;
    internal bool IncludesColumnNames {
        get {
            return columns;
        }
        set {
            columns = value;
        }
    }

    // Get data from the underlying data source.
    // Build and return a DataView, regardless of mode.
    protected override IEnumerable ExecuteSelect(DataSourceSelectArguments
 selectArgs) {
        IEnumerable dataList = null;
        // Open the .csv file.
        if (File.Exists(this.SourceFile)) {
            DataTable data = new DataTable();

            // Open the file to read from.
            using (StreamReader sr = File.OpenText(this.SourceFile))
 {
                // Parse the line
                string s = "";
                string[] dataValues;
                DataColumn col;

                // Do the following to add schema.
                dataValues = sr.ReadLine().Split(',');
                // For each token in the comma-delimited string, add
 a column
                // to the DataTable schema.
                foreach (string token in
 dataValues) {
                    col = new DataColumn(token,typeof(string));
                    data.Columns.Add(col);
                }

                // Do not add the first row as data if the CSV file
 includes column names.
                if (! IncludesColumnNames)
                    data.Rows.Add(CopyRowData(dataValues, data.NewRow()));

                // Do the following to add data.
                while ((s = sr.ReadLine()) != null)
 {
                    dataValues = s.Split(',');
                    data.Rows.Add(CopyRowData(dataValues, data.NewRow()));
                }
            }
            data.AcceptChanges();
            DataView dataView = new DataView(data);
            if (selectArgs.SortExpression != String.Empty) {
                dataView.Sort = selectArgs.SortExpression;
            }
            dataList = dataView;
        }
        else {
            throw new System.Configuration.ConfigurationErrorsException("File
 not found, " + this.SourceFile);
        }

        if (null == dataList) {
            throw new InvalidOperationException("No data
 loaded from data source.");
        }

        return dataList;
    }

    private DataRow CopyRowData(string[] source,
 DataRow target) {
        try {
            for (int i = 0;i < source.Length;i++)
 {
                target[i] = source[i];
            }
        }
        catch (System.IndexOutOfRangeException) {
            // There are more columns in this row than
            // the original schema allows.  Stop copying
            // and return the DataRow.
            return target;
        }
        return target;
    }
    // The CsvDataSourceView does not currently
    // permit deletion. You can modify or extend
    // this sample to do so.
    public override bool CanDelete {
        get {
            return false;
        }
    }
    protected override int ExecuteDelete(IDictionary
 keys, IDictionary values)
    {
        throw new NotSupportedException();
    }
    // The CsvDataSourceView does not currently
    // permit insertion of a new record. You can
    // modify or extend this sample to do so.
    public override bool CanInsert {
        get {
            return false;
        }
    }
    protected override int ExecuteInsert(IDictionary
 values)
    {
        throw new NotSupportedException();
    }
    // The CsvDataSourceView does not currently
    // permit update operations. You can modify or
    // extend this sample to do so.
    public override bool CanUpdate {
        get {
            return false;
        }
    }
    protected override int ExecuteUpdate(IDictionary
 keys, IDictionary values, IDictionary oldValues)
    {
        throw new NotSupportedException();
    }
}
.NET Framework のセキュリティ.NET Framework のセキュリティ
継承階層継承階層
System.Object
   System.Web.UI.Control
    System.Web.UI.DataSourceControl
       System.Web.UI.WebControls.ObjectDataSource
       System.Web.UI.WebControls.SqlDataSource
スレッド セーフスレッド セーフ
この型の public static (Visual Basic では Shared) メンバはすべて、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
DataSourceControl メンバ
System.Web.UI 名前空間
IDataSource
DataSourceView
DataBoundControl
HierarchicalDataSourceControl

DataSourceControl コンストラクタ


DataSourceControl プロパティ


パブリック プロパティパブリック プロパティ

( プロテクト プロパティ も参照)
  名前 説明
パブリック プロパティ AppRelativeTemplateSourceDirectory  このコントロールが含まれている Page オブジェクトまたは UserControl オブジェクトのアプリケーション相対の仮想ディレクトリを取得または設定します。 ( Control から継承されます。)
パブリック プロパティ BindingContainer  このコントロールのデータ バインディングを格納しているコントロールを取得します。 ( Control から継承されます。)
パブリック プロパティ ClientID ASP.NET によって生成されたサーバー コントロール ID を取得します。
パブリック プロパティ Controls UI 階層構造の指定されたサーバー コントロールの子コントロールを表す ControlCollection オブジェクトを取得します。
パブリック プロパティ EnableTheming このコントロールがテーマをサポートしているかどうかを示す値を取得します。
パブリック プロパティ EnableViewState  サーバー コントロールが、そのビューステートおよび格納している子コントロールのビューステートを、要求しているクライアントに永続化させるかどうかを示す値を取得または設定します。 ( Control から継承されます。)
パブリック プロパティ ID  サーバー コントロールに割り当てられたプログラム ID を取得または設定します。 ( Control から継承されます。)
パブリック プロパティ NamingContainer  同じ Control.ID プロパティ値を持つ複数のサーバー コントロールを区別するための一意の名前空間を作成する、サーバー コントロールの名前付けコンテナへの参照を取得します。 ( Control から継承されます。)
パブリック プロパティ Page  サーバー コントロールを含んでいる Page インスタンスへの参照を取得します。 ( Control から継承されます。)
パブリック プロパティ Parent  ページ コントロールの階層構造における、サーバー コントロールの親コントロールへの参照を取得します。 ( Control から継承されます。)
パブリック プロパティ Site  デザイン サーフェイスに現在のコントロールを表示するときに、このコントロールをホストするコンテナに関する情報を取得します。 ( Control から継承されます。)
パブリック プロパティ SkinID DataSourceControl コントロールに適用するスキンを取得します。
パブリック プロパティ TemplateControl  このコントロールを格納しているテンプレートへの参照を取得または設定します。 ( Control から継承されます。)
パブリック プロパティ TemplateSourceDirectory  現在のサーバー コントロールを格納している Page または UserControl の仮想ディレクトリを取得します。 ( Control から継承されます。)
パブリック プロパティ UniqueID  階層構造で修飾されたサーバー コントロールの一意の ID を取得します。 ( Control から継承されます。)
パブリック プロパティ Visible コントロールが視覚的に表示されているかどうかを示す値を取得または設定します。
プロテクト プロパティプロテクト プロパティ
  名前 説明
プロテクト プロパティ Adapter  コントロール用のブラウザ固有のアダプタを取得します。 ( Control から継承されます。)
プロテクト プロパティ ChildControlsCreated  サーバー コントロールの子コントロールが作成されたかどうかを示す値を取得します。 ( Control から継承されます。)
プロテクト プロパティ ClientIDSeparator  ClientID プロパティで使用される区切り記号を表す文字値を取得します。 ( Control から継承されます。)
プロテクト プロパティ Context  現在の Web 要求に対するサーバー コントロールに関連付けられている HttpContext オブジェクトを取得します。 ( Control から継承されます。)
プロテクト プロパティ DesignMode  コントロールがデザイン サーフェイスで使用されているかどうかを示す値を取得します。 ( Control から継承されます。)
プロテクト プロパティ Events  コントロールのイベント ハンドラ デリゲートのリストを取得します。このプロパティは読み取り専用です。 ( Control から継承されます。)
プロテクト プロパティ HasChildViewState  現在のサーバー コントロールの子コントロールが、保存されたビューステートの設定を持っているかどうかを示す値を取得します。 ( Control から継承されます。)
プロテクト プロパティ IdSeparator  コントロール ID を区別するために使用する文字を取得します。 ( Control から継承されます。)
プロテクト プロパティ IsChildControlStateCleared  このコントロールに含まれているコントロールに、コントロールの状態が設定されているかどうかを示す値を取得します。 ( Control から継承されます。)
プロテクト プロパティ IsTrackingViewState  サーバー コントロールがビューステートの変更を保存しているかどうかを示す値を取得します。 ( Control から継承されます。)
プロテクト プロパティ IsViewStateEnabled  このコントロールでビューステートが有効かどうかを示す値を取得します。 ( Control から継承されます。)
プロテクト プロパティ LoadViewStateByID  コントロールがインデックスではなく ID によりビューステートの読み込みを行うかどうかを示す値を取得します。 ( Control から継承されます。)
プロテクト プロパティ ViewState  同一のページに対する複数の要求にわたって、サーバー コントロールのビューステートを保存し、復元できるようにする状態情報のディクショナリを取得します。 ( Control から継承されます。)
プロテクト プロパティ ViewStateIgnoresCase  StateBag オブジェクトが大文字小文字を区別しないかどうかを示す値を取得します。 ( Control から継承されます。)
明示的インターフェイスの実装明示的インターフェイスの実装
  名前 説明
インターフェイスの明示的な実装 System.ComponentModel.IListSource.ContainsListCollection データ ソース コントロールが 1 つ以上のデータのリストに関連付けられているかどうかを示します。
参照参照

関連項目

DataSourceControl クラス
System.Web.UI 名前空間
IDataSource
DataSourceView
DataBoundControl
HierarchicalDataSourceControl

DataSourceControl メソッド


パブリック メソッドパブリック メソッド

( プロテクト メソッド も参照)
  名前 説明
パブリック メソッド ApplyStyleSheetSkin オーバーライドされます。 ページのスタイル シートに定義されたスタイル プロパティをコントロールに適用します。
パブリック メソッド DataBind  オーバーロードされます。 呼び出されたサーバー コントロールと、そのすべての子コントロールにデータ ソースを連結します。 ( Control から継承されます。)
パブリック メソッド Dispose  サーバー コントロールが、メモリから解放される前に最終的なクリーンアップを実行できるようにします。 ( Control から継承されます。)
パブリック メソッド Equals  オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。)
パブリック メソッド FindControl オーバーロードされます。 オーバーライドされます。  
パブリック メソッド Focus オーバーライドされます。 コントロールに入力フォーカスを設定します。
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。)
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 ( Object から継承されます。)
パブリック メソッド HasControls オーバーライドされます。 サーバー コントロールに子コントロールが含まれているかどうかを確認します。
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。)
パブリック メソッド RenderControl オーバーロードされます。 オーバーライドされます。  
パブリック メソッド ResolveClientUrl  ブラウザで使用できる URL を取得します。 ( Control から継承されます。)
パブリック メソッド ResolveUrl  要求側クライアントで使用できる URL に変換します。 ( Control から継承されます。)
パブリック メソッド SetRenderMethodDelegate  サーバー コントロールとその内容を親コントロールに表示するイベント ハンドラ デリゲートを割り当てます。 ( Control から継承されます。)
パブリック メソッド ToString  現在の Object を表す String を返します。 ( Object から継承されます。)
プロテクト メソッドプロテクト メソッド
  名前 説明
プロテクト メソッド AddedControl  子コントロールが Control オブジェクトの Controls コレクションに追加された後に呼び出されます。 ( Control から継承されます。)
プロテクト メソッド AddParsedSubObject  サーバー コントロールに、XML または HTML の要素が解析されたことを通知し、その要素をサーバー コントロールの ControlCollection オブジェクトに追加します。 ( Control から継承されます。)
プロテクト メソッド BuildProfileTree  ページのトレースが有効な場合、サーバー コントロールに関する情報を収集し、これを表示するために Trace プロパティに渡します。 ( Control から継承されます。)
プロテクト メソッド ClearChildControlState  サーバー コントロールのすべての子コントロールについて、コントロールの状態情報を削除します。 ( Control から継承されます。)
プロテクト メソッド ClearChildState  サーバー コントロールのすべての子コントロールのビューステート情報およびコントロールの状態情報を削除します。 ( Control から継承されます。)
プロテクト メソッド ClearChildViewState  サーバー コントロールのすべての子コントロールのビューステート情報を削除します。 ( Control から継承されます。)
プロテクト メソッド CreateChildControls  ASP.NET ページ フレームワークによって呼び出され、コンポジション ベースの実装を使用するサーバー コントロールに、ポスト バックまたは表示のための準備として、格納する子コントロールを作成するように通知します。 ( Control から継承されます。)
プロテクト メソッド CreateControlCollection オーバーライドされます。 子コントロールを格納するコレクションを作成します。
プロテクト メソッド DataBind  オーバーロードされます。 呼び出されたサーバー コントロールと、そのすべての子コントロールにデータ ソースを連結します。 ( Control から継承されます。)
プロテクト メソッド DataBindChildren  データ ソースをサーバー コントロールの子コントロールにバインドします。 ( Control から継承されます。)
プロテクト メソッド EnsureChildControls  サーバー コントロールに子コントロールが含まれているかどうかを確認します。含まれていない場合、子コントロールを作成します。 ( Control から継承されます。)
プロテクト メソッド EnsureID  ID が割り当てられていないコントロールの ID を作成します。 ( Control から継承されます。)
プロテクト メソッド Finalize  Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。)
プロテクト メソッド FindControl  オーバーロードされます。 指定したサーバー コントロールの現在の名前付けコンテナを検索します。 ( Control から継承されます。)
プロテクト メソッド GetDesignModeState  コントロールのデザイン時データを取得します。 ( Control から継承されます。)
プロテクト メソッド GetView データ ソース コントロールに関連付けられた名前付きデータ ソース ビューを取得します。
プロテクト メソッド GetViewNames DataSourceControl コントロールに関連付けられた DataSourceView オブジェクトのリストを表す名前のコレクションを取得します。
プロテクト メソッド HasEvents  コントロールまたは子コントロールに対してイベントが登録されているかどうかを示す値を返します。 ( Control から継承されます。)
プロテクト メソッド IsLiteralContent  サーバー コントロールがリテラルな内容だけを保持しているかどうかを決定します。 ( Control から継承されます。)
プロテクト メソッド LoadControlState  SaveControlState メソッドによって保存された前回のページ要求からコントロールの状態情報を復元します。 ( Control から継承されます。)
プロテクト メソッド LoadViewState  SaveViewState メソッドによって保存された前回のページ要求からビューステート情報を復元します。 ( Control から継承されます。)
プロテクト メソッド MapPathSecure  仮想パス (絶対パスまたは相対パス) の割り当て先の物理パスを取得します。 ( Control から継承されます。)
プロテクト メソッド MemberwiseClone  現在の Object の簡易コピーを作成します。 ( Object から継承されます。)
プロテクト メソッド OnBubbleEvent  サーバー コントロールのイベントをページの UI サーバー コントロールの階層構造に渡すかどうかを決定します。 ( Control から継承されます。)
プロテクト メソッド OnDataBinding  DataBinding イベントを発生させます。 ( Control から継承されます。)
プロテクト メソッド OnInit  Init イベントを発生させます。 ( Control から継承されます。)
プロテクト メソッド OnLoad  Load イベントを発生させます。 ( Control から継承されます。)
プロテクト メソッド OnPreRender  PreRender イベントを発生させます。 ( Control から継承されます。)
プロテクト メソッド OnUnload  Unload イベントを発生させます。 ( Control から継承されます。)
プロテクト メソッド OpenFile  ファイルの読み込みで使用される Stream を取得します。 ( Control から継承されます。)
プロテクト メソッド RaiseBubbleEvent  イベントのソースおよびその情報をコントロールの親に割り当てます。 ( Control から継承されます。)
プロテクト メソッド RaiseDataSourceChangedEvent DataSourceChanged イベントを発生させます。
プロテクト メソッド RemovedControl  子コントロールが Control オブジェクトの Controls コレクションから削除された後に呼び出されます。 ( Control から継承されます。)
プロテクト メソッド Render  提供されたクライアントに表示される内容を書き込む HtmlTextWriter オブジェクトに、サーバー コントロールの内容を送信します。 ( Control から継承されます。)
プロテクト メソッド RenderChildren  クライアントに表示される内容の書き込みを行う、指定された HtmlTextWriter オブジェクトに、サーバー コントロールの子を出力します。 ( Control から継承されます。)
プロテクト メソッド RenderControl  オーバーロードされます。 サーバー コントロールの内容を出力し、トレースが有効である場合はコントロールに関するトレース情報を格納します。 ( Control から継承されます。)
プロテクト メソッド ResolveAdapter  指定したコントロールを表示するコントロール アダプタを取得します。 ( Control から継承されます。)
プロテクト メソッド SaveControlState  ページがサーバーにポスト バックされた時間以降に発生した、サーバー コントロールの状態の変更を保存します。 ( Control から継承されます。)
プロテクト メソッド SaveViewState  ページがサーバーにポスト バックされた時間以降に発生した、サーバー コントロールのビューステートの変更を保存します。 ( Control から継承されます。)
プロテクト メソッド SetDesignModeState  コントロールのデザイン時データを設定します。 ( Control から継承されます。)
プロテクト メソッド TrackViewState  サーバー コントロールにビューステートの変更を追跡させ、サーバー コントロールの StateBag オブジェクトに変更を格納できるようにします。このオブジェクトは、Control.ViewState プロパティによってアクセスできます。 ( Control から継承されます。)
明示的インターフェイスの実装明示的インターフェイスの実装
  名前 説明
インターフェイスの明示的な実装 System.ComponentModel.IListSource.GetList データのリストのソースとして使用できるデータ ソース コントロールのリストを取得します。
インターフェイスの明示的な実装 System.Web.UI.IDataSource.GetView DataSourceControl コントロールに関連付けられている名前付きの DataSourceView オブジェクトを取得します。データ ソース コントロールには、1 つのビューしかサポートしていないものもあれば、複数のビューをサポートするものもあります。
インターフェイスの明示的な実装 System.Web.UI.IDataSource.GetViewNames DataSourceControl コントロールに関連付けられた DataSourceView オブジェクトのリストを表す名前のコレクションを取得します。
参照参照

関連項目

DataSourceControl クラス
System.Web.UI 名前空間
IDataSource
DataSourceView
DataBoundControl
HierarchicalDataSourceControl

DataSourceControl メンバ

データ バインド コントロールに対してデータ ソースを表すコントロールの基本クラスとして機能します。

DataSourceControl データ型で公開されるメンバを以下の表に示します。


プロテクト コンストラクタプロテクト コンストラクタ
  名前 説明
プロテクト メソッド DataSourceControl DataSourceControl クラスの新しいインスタンスを初期化します。
パブリック プロパティパブリック プロパティ
( プロテクト プロパティ も参照)
  名前 説明
パブリック プロパティ AppRelativeTemplateSourceDirectory  このコントロールが含まれている Page オブジェクトまたは UserControl オブジェクトのアプリケーション相対の仮想ディレクトリを取得または設定します。(Control から継承されます。)
パブリック プロパティ BindingContainer  このコントロールのデータ バインディングを格納しているコントロールを取得します。(Control から継承されます。)
パブリック プロパティ ClientID ASP.NET によって生成されたサーバー コントロール ID を取得します。
パブリック プロパティ Controls UI 階層構造の指定されたサーバー コントロールの子コントロールを表す ControlCollection オブジェクトを取得します。
パブリック プロパティ EnableTheming このコントロールがテーマをサポートしているかどうかを示す値を取得します。
パブリック プロパティ EnableViewState  サーバー コントロールが、そのビューステートおよび格納している子コントロールのビューステートを、要求しているクライアントに永続化させるかどうかを示す値を取得または設定します。(Control から継承されます。)
パブリック プロパティ ID  サーバー コントロールに割り当てられたプログラム ID を取得または設定します。(Control から継承されます。)
パブリック プロパティ NamingContainer  同じ Control.ID プロパティ値を持つ複数のサーバー コントロールを区別するための一意の名前空間を作成する、サーバー コントロールの名前付けコンテナへの参照を取得します。(Control から継承されます。)
パブリック プロパティ Page  サーバー コントロールを含んでいる Page インスタンスへの参照を取得します。(Control から継承されます。)
パブリック プロパティ Parent  ページ コントロールの階層構造における、サーバー コントロールの親コントロールへの参照を取得します。(Control から継承されます。)
パブリック プロパティ Site  デザイン サーフェイスに現在のコントロールを表示するときに、このコントロールをホストするコンテナに関する情報を取得します。(Control から継承されます。)
パブリック プロパティ SkinID DataSourceControl コントロールに適用するスキンを取得します。
パブリック プロパティ TemplateControl  このコントロールを格納しているテンプレートへの参照を取得または設定します。 (Control から継承されます。)
パブリック プロパティ TemplateSourceDirectory  現在のサーバー コントロールを格納している Page または UserControl の仮想ディレクトリを取得します。(Control から継承されます。)
パブリック プロパティ UniqueID  階層構造で修飾されたサーバー コントロールの一意の ID を取得します。(Control から継承されます。)
パブリック プロパティ Visible コントロールが視覚的に表示されているかどうかを示す値を取得または設定します。
プロテクト プロパティプロテクト プロパティ
  名前 説明
プロテクト プロパティ Adapter  コントロール用のブラウザ固有のアダプタを取得します。(Control から継承されます。)
プロテクト プロパティ ChildControlsCreated  サーバー コントロールの子コントロールが作成されたかどうかを示す値を取得します。(Control から継承されます。)
プロテクト プロパティ ClientIDSeparator  ClientID プロパティで使用される区切り記号を表す文字値を取得します。(Control から継承されます。)
プロテクト プロパティ Context  現在の Web 要求に対するサーバー コントロールに関連付けられている HttpContext オブジェクトを取得します。(Control から継承されます。)
プロテクト プロパティ DesignMode  コントロールがデザイン サーフェイスで使用されているかどうかを示す値を取得します。(Control から継承されます。)
プロテクト プロパティ Events  コントロールのイベント ハンドラ デリゲートのリストを取得します。このプロパティは読み取り専用です。(Control から継承されます。)
プロテクト プロパティ HasChildViewState  現在のサーバー コントロールの子コントロールが、保存されたビューステートの設定を持っているかどうかを示す値を取得します。(Control から継承されます。)
プロテクト プロパティ IdSeparator  コントロール ID を区別するために使用する文字を取得します。(Control から継承されます。)
プロテクト プロパティ IsChildControlStateCleared  このコントロールに含まれているコントロールに、コントロールの状態が設定されているかどうかを示す値を取得します。(Control から継承されます。)
プロテクト プロパティ IsTrackingViewState  サーバー コントロールがビューステートの変更を保存しているかどうかを示す値を取得します。(Control から継承されます。)
プロテクト プロパティ IsViewStateEnabled  このコントロールでビューステートが有効かどうかを示す値を取得します。(Control から継承されます。)
プロテクト プロパティ LoadViewStateByID  コントロールがインデックスではなく ID によりビューステートの読み込みを行うかどうかを示す値を取得します。 (Control から継承されます。)
プロテクト プロパティ ViewState  同一のページに対する複数の要求にわたって、サーバー コントロールのビューステートを保存し、復元できるようにする状態情報のディクショナリを取得します。(Control から継承されます。)
プロテクト プロパティ ViewStateIgnoresCase  StateBag オブジェクトが大文字小文字を区別しないかどうかを示す値を取得します。(Control から継承されます。)
パブリック メソッドパブリック メソッド
( プロテクト メソッド も参照)
  名前 説明
パブリック メソッド ApplyStyleSheetSkin オーバーライドされます。 ページのスタイル シートに定義されたスタイル プロパティをコントロールに適用します。
パブリック メソッド DataBind  オーバーロードされます。 呼び出されたサーバー コントロールと、そのすべての子コントロールにデータ ソースを連結します。 (Control から継承されます。)
パブリック メソッド Dispose  サーバー コントロールが、メモリから解放される前に最終的なクリーンアップを実行できるようにします。 (Control から継承されます。)
パブリック メソッド Equals  オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。)
パブリック メソッド FindControl オーバーロードされます。 オーバーライドされます。  
パブリック メソッド Focus オーバーライドされます。 コントロールに入力フォーカスを設定します。
パブリック メソッド GetHashCode  特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。)
パブリック メソッド GetType  現在のインスタンスの Type を取得します。 (Object から継承されます。)
パブリック メソッド HasControls オーバーライドされます。 サーバー コントロールに子コントロールが含まれているかどうかを確認します。
パブリック メソッド ReferenceEquals  指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。)
パブリック メソッド RenderControl オーバーロードされます。 オーバーライドされます。  
パブリック メソッド ResolveClientUrl  ブラウザで使用できる URL を取得します。 (Control から継承されます。)
パブリック メソッド ResolveUrl  要求側クライアントで使用できる URL に変換します。 (Control から継承されます。)
パブリック メソッド SetRenderMethodDelegate  サーバー コントロールとその内容を親コントロールに表示するイベント ハンドラ デリゲートを割り当てます。 (Control から継承されます。)
パブリック メソッド ToString  現在の Object を表す String を返します。 (Object から継承されます。)
プロテクト メソッドプロテクト メソッド
  名前 説明
プロテクト メソッド AddedControl  子コントロールが Control オブジェクトの Controls コレクションに追加された後に呼び出されます。 (Control から継承されます。)
プロテクト メソッド AddParsedSubObject  サーバー コントロールに、XML または HTML の要素が解析されたことを通知し、その要素をサーバー コントロールの ControlCollection オブジェクトに追加します。 (Control から継承されます。)
プロテクト メソッド BuildProfileTree  ページのトレースが有効な場合、サーバー コントロールに関する情報を収集し、これを表示するために Trace プロパティに渡します。 (Control から継承されます。)
プロテクト メソッド ClearChildControlState  サーバー コントロールのすべての子コントロールについて、コントロールの状態情報を削除します。 (Control から継承されます。)
プロテクト メソッド ClearChildState  サーバー コントロールのすべての子コントロールのビューステート情報およびコントロールの状態情報を削除します。 (Control から継承されます。)
プロテクト メソッド ClearChildViewState  サーバー コントロールのすべての子コントロールのビューステート情報を削除します。 (Control から継承されます。)
プロテクト メソッド CreateChildControls  ASP.NET ページ フレームワークによって呼び出され、コンポジション ベースの実装を使用するサーバー コントロールに、ポスト バックまたは表示のための準備として、格納する子コントロールを作成するように通知します。 (Control から継承されます。)
プロテクト メソッド CreateControlCollection オーバーライドされます。 子コントロールを格納するコレクションを作成します。
プロテクト メソッド DataBind  オーバーロードされます。 呼び出されたサーバー コントロールと、そのすべての子コントロールにデータ ソースを連結します。 (Control から継承されます。)
プロテクト メソッド DataBindChildren  データ ソースをサーバー コントロールの子コントロールにバインドします。 (Control から継承されます。)
プロテクト メソッド EnsureChildControls  サーバー コントロールに子コントロールが含まれているかどうかを確認します。含まれていない場合、子コントロールを作成します。 (Control から継承されます。)
プロテクト メソッド EnsureID  ID が割り当てられていないコントロールの ID を作成します。 (Control から継承されます。)
プロテクト メソッド Finalize  Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。)
プロテクト メソッド FindControl  オーバーロードされます。 指定したサーバー コントロールの現在の名前付けコンテナを検索します。 (Control から継承されます。)
プロテクト メソッド GetDesignModeState  コントロールのデザイン時データを取得します。 (Control から継承されます。)
プロテクト メソッド GetView データ ソース コントロールに関連付けられた名前付きデータ ソース ビューを取得します。
プロテクト メソッド GetViewNames DataSourceControl コントロールに関連付けられた DataSourceView オブジェクトのリストを表す名前のコレクションを取得します。
プロテクト メソッド HasEvents  コントロールまたは子コントロールに対してイベントが登録されているかどうかを示す値を返します。 (Control から継承されます。)
プロテクト メソッド IsLiteralContent  サーバー コントロールがリテラルな内容だけを保持しているかどうかを決定します。 (Control から継承されます。)
プロテクト メソッド LoadControlState  SaveControlState メソッドによって保存された前回のページ要求からコントロールの状態情報を復元します。 (Control から継承されます。)
プロテクト メソッド LoadViewState  SaveViewState メソッドによって保存された前回のページ要求からビューステート情報を復元します。 (Control から継承されます。)
プロテクト メソッド MapPathSecure  仮想パス (絶対パスまたは相対パス) の割り当て先の物理パスを取得します。 (Control から継承されます。)
プロテクト メソッド MemberwiseClone  現在の Object の簡易コピーを作成します。 (Object から継承されます。)
プロテクト メソッド OnBubbleEvent  サーバー コントロールのイベントをページの UI サーバー コントロールの階層構造に渡すかどうかを決定します。 (Control から継承されます。)
プロテクト メソッド OnDataBinding  DataBinding イベントを発生させます。 (Control から継承されます。)
プロテクト メソッド OnInit  Init イベントを発生させます。 (Control から継承されます。)
プロテクト メソッド OnLoad  Load イベントを発生させます。 (Control から継承されます。)
プロテクト メソッド OnPreRender  PreRender イベントを発生させます。 (Control から継承されます。)
プロテクト メソッド OnUnload  Unload イベントを発生させます。 (Control から継承されます。)
プロテクト メソッド OpenFile  ファイルの読み込みで使用される Stream を取得します。 (Control から継承されます。)
プロテクト メソッド RaiseBubbleEvent  イベントのソースおよびその情報をコントロールの親に割り当てます。 (Control から継承されます。)
プロテクト メソッド RaiseDataSourceChangedEvent DataSourceChanged イベントを発生させます。
プロテクト メソッド RemovedControl  子コントロールが Control オブジェクトの Controls コレクションから削除された後に呼び出されます。 (Control から継承されます。)
プロテクト メソッド Render  提供されたクライアントに表示される内容を書き込む HtmlTextWriter オブジェクトに、サーバー コントロールの内容を送信します。 (Control から継承されます。)
プロテクト メソッド RenderChildren  クライアントに表示される内容の書き込みを行う、指定された HtmlTextWriter オブジェクトに、サーバー コントロールの子を出力します。 (Control から継承されます。)
プロテクト メソッド RenderControl  オーバーロードされます。 サーバー コントロールの内容を出力し、トレースが有効である場合はコントロールに関するトレース情報を格納します。 (Control から継承されます。)
プロテクト メソッド ResolveAdapter  指定したコントロールを表示するコントロール アダプタを取得します。 (Control から継承されます。)
プロテクト メソッド SaveControlState  ページがサーバーにポスト バックされた時間以降に発生した、サーバー コントロールの状態の変更を保存します。 (Control から継承されます。)
プロテクト メソッド SaveViewState  ページがサーバーにポスト バックされた時間以降に発生した、サーバー コントロールのビューステートの変更を保存します。 (Control から継承されます。)
プロテクト メソッド SetDesignModeState  コントロールのデザイン時データを設定します。 (Control から継承されます。)
プロテクト メソッド TrackViewState  サーバー コントロールにビューステートの変更を追跡させ、サーバー コントロールの StateBag オブジェクトに変更を格納できるようにします。このオブジェクトは、Control.ViewState プロパティによってアクセスできます。 (Control から継承されます。)
パブリック イベントパブリック イベント
明示的インターフェイスの実装明示的インターフェイスの実装
  名前 説明
インターフェイスの明示的な実装 System.ComponentModel.IListSource.GetList データのリストのソースとして使用できるデータ ソース コントロールのリストを取得します。
インターフェイスの明示的な実装 System.Web.UI.IDataSource.GetView DataSourceControl コントロールに関連付けられている名前付きの DataSourceView オブジェクトを取得します。データ ソース コントロールには、1 つのビューしかサポートしていないものもあれば、複数のビューをサポートするものもあります。
インターフェイスの明示的な実装 System.Web.UI.IDataSource.GetViewNames DataSourceControl コントロールに関連付けられた DataSourceView オブジェクトのリストを表す名前のコレクションを取得します。
インターフェイスの明示的な実装 System.Web.UI.IDataSource.DataSourceChanged  
参照参照

関連項目

DataSourceControl クラス
System.Web.UI 名前空間
IDataSource
DataSourceView
DataBoundControl
HierarchicalDataSourceControl


英和和英テキスト翻訳

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

辞書ショートカット

すべての辞書の索引

「data source control」の関連用語

data source controlのお隣キーワード
検索ランキング

   

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



data source controlのページの著作権

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

©2026 GRAS Group, Inc.RSS