次の方法で共有


IDataSourceProvider.GetSelectedDataSource メソッド

このデータ ソース プロバイダの選択したデータ ソースへの参照を取得します。

Function GetSelectedDataSource() As Object
[C#]
object GetSelectedDataSource();
[C++]
Object* GetSelectedDataSource();
[JScript]
function GetSelectedDataSource() : Object;

戻り値

このデータ ソース プロバイダの現在選択されているデータ ソース オブジェクト。

使用例

[Visual Basic] IDataSourceProvider インターフェイスの GetSelectedDataSource メソッドと GetResolvedSelectedDataSource メソッドの両方を実装するコード例を次に示します。 GetSelectedDataSource メソッドは、デザイン時にコントロールに関連付けられているデータ ソースが、 IEnumerable インターフェイスを実装するオブジェクトであることを確認します。これによりユーザーは、データ ソースを反復処理できるようになります。

 
' Create a method that implements the 
' IDataSourceProvider.GetResolvedSelectedDataSource method.
' It converts the object returned from the GetSelectedDataSource
' method into an IEnumberable object to allow iteration over
' the returned object.
Function GetResolvedSelectedDataSource() As IEnumerable _
 Implements IDataSourceProvider.GetResolvedSelectedDataSource
   Return CType(CType(Me, IDataSourceProvider).GetSelectedDataSource(), IEnumerable)
End Function
 
' Create a method that implements the 
' IDataSourceProvider.GetSelectedDataSource method. 
' Return the data source as an IEnumerable object,
' if possible.     
Function GetSelectedDataSource() As Object _
 Implements IDataSourceProvider.GetSelectedDataSource
   Dim selectedDataSource As Object = Nothing
   Dim dataSource As String = Nothing
   
   Dim binding As DataBinding = DataBindings("DataSource")
   If Not (binding Is Nothing) Then
      dataSource = binding.Expression
   End If
    
   If Not (dataSource Is Nothing) Then
      Dim componentSite As ISite = Component.Site
      If Not (componentSite Is Nothing) Then
         Dim container As IContainer = CType(componentSite.GetService(GetType(IContainer)), IContainer)
         
         If Not (container Is Nothing) Then
            Dim comp As IComponent = container.Components(dataSource)
            If TypeOf comp Is IEnumerable Then
               selectedDataSource = comp
            End If
         End If
      End If
   End If
   
   Return selectedDataSource
End Function

[C#, C++, JScript] C#、C++、および JScript のサンプルはありません。Visual Basic のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 2000, Windows XP Professional, Windows Server 2003 ファミリ

.NET Framework セキュリティ:

参照

IDataSourceProvider インターフェイス | IDataSourceProvider メンバ | System.Web.UI.Design 名前空間