GetResolvedSelectedDataSource Method
Collapse the table of content
Expand the table of content

IDataSourceProvider.GetResolvedSelectedDataSource Method

Gets the selected data member from the selected data source.

[Visual Basic]
Function GetResolvedSelectedDataSource() As IEnumerable
[C#]
IEnumerable GetResolvedSelectedDataSource();
[C++]
IEnumerable* GetResolvedSelectedDataSource();
[JScript]
function GetResolvedSelectedDataSource() : IEnumerable;

Return Value

The selected data member from the selected data source, if the control allows the user to select an IListSource (such as a DataSet) for the data source. It also provides a DataMember property that allows you to select the returned list (or DataTable) within the data source.

Example

[Visual Basic] The following code example implements the GetResolvedSelectedDataSource and the GetSelectedDataSource methods of the IDataSourceProvider interface. While the GetSelectedDataSource method gets an arbitrary object as the data source, this implementation of the GetResolvedSelectedDataSource method converts that object into an IEnumerable object.

[Visual Basic] 
' 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] No example is available for C#, C++, or JScript. To view a Visual Basic example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 2000, Windows XP Professional, Windows Server 2003 family

.NET Framework Security: 

See Also

IDataSourceProvider Interface | IDataSourceProvider Members | System.Web.UI.Design Namespace

Show:
© 2016 Microsoft