Partager via


IListProvider.ListReady - Événement

Remarque : cette API est désormais obsolète.

Se produit lorsque la liste entière a été extraite et est prête à être envoyée à un composant qui implémente l'interface IListConsumer .

Espace de noms :  Microsoft.SharePoint.WebPartPages.Communication
Assembly :  Microsoft.SharePoint (dans Microsoft.SharePoint.dll)

Syntaxe

'Déclaration
<ObsoleteAttribute("Use System.Web.UI.WebControls.WebParts.IWebPartTable instead")> _
Event ListReady As ListReadyEventHandler
'Utilisation
Dim instance As IListProvider
Dim handler As ListReadyEventHandler

AddHandler instance.ListReady, handler
[ObsoleteAttribute("Use System.Web.UI.WebControls.WebParts.IWebPartTable instead")]
event ListReadyEventHandler ListReady

Remarques

Le Gestionnaire d'événements reçoit un argument de type Microsoft.SharePoint.WebPartPages.Communication.ListReadyEventArgs contenant des données liées à cet événement. La propriété ListReadyEventArgs.List fournit des informations spécifiques à cet événement.

Le ListReady doit également être déclenché lors de la modification de la liste fournie (par exemple, lorsqu'une addition, la suppression, la mise à jour d'une ligne ou un changement de filtre se produit).

Exemples

L'exemple de code suivant substitue la méthode PartCommunicationMain et déclenche l'événement ListReady . Cet exemple de code fait partie d'un exemple plus développé fourni pour l'interface IListProvider .

      ' Step #8: Override the PartCommunicationMain method.
      ' The PartCommunicationMain method is called by the Web Part 
      ' infrastructure on the client during the ASP.NET PreRender
      ' event to allow the part to pass its primary data to the other 
      ' connected parts. It is important to always fire the ListReady 
      ' or PartialListReady event. Some parts
      ' may not behave properly if they are left waiting for this 
      ' information.
       Public Overrides Sub PartCommunicationMain()
            ' Ensure that all of the Web Part's controls are created.
            EnsureChildControls()

            'Check if connected
            If _connected Then                
                    ' Create the ListReadyEventArgs object for the ListProviderInit event.
                    Dim listReadyArgs As New ListReadyEventArgs()

                    ' If user clicked button, send the value.
                    If _listButtonClicked Then
                        ' Set the List to the value of the table in the 
                        ' DataGrid. This is the value that will be sent 
                        ' to the consumer Web Part.
                        listReadyArgs.List = CType(_dataGrid.DataSource, DataTable)
                    Else
                        ' The user didn't click the button, so send a
                        ' null DataTable to the consumer Web Part.
                        listReadyArgs.List = Nothing
                    End If

                    ' Fire the ListReady event.
                    ' The consumer Web Part will receive the DataTable.
                    RaiseEvent ListReady(Me, listReadyArgs)                
            End If
        End Sub 
// Step #8: Override the PartCommunicationMain method.
// The PartCommunicationMain method is called by the Web Part 
// infrastructure on the client during the ASP.NET PreRender
// event to allow the part to pass its primary data to the other 
// connected parts. 
// It is important to always fire the ListReady or PartialListReady 
// event. Some parts may not behave properly if they are left waiting 
// for this information.
public override void PartCommunicationMain()
{
    // Ensure that all of the Web Part's controls are created.
    EnsureChildControls();

    //Check if connected
    if(_connected)
    {
        // If there is a listener, fire the ListReady event.
        if (ListReady != null)
        {
            // Create the ListReadyEventArgs object for the 
            // ListProviderInit event.
            ListReadyEventArgs listReadyArgs = new ListReadyEventArgs();

            // If user clicked button, send the value.
            if (_listButtonClicked)
            {
                // Set the List to the value of the table in the 
                // DataGrid.
                // This is the value that will be sent to the consumer 
                // Web Part.
                listReadyArgs.List = ((DataTable)_dataGrid.DataSource);
            }
            else
            {
                // The user didn't click the button, so send a
                // null DataTable to the consumer Web Part.
                listReadyArgs.List = null;
            }

            // Fire the ListReady event.
            // The consumer Web Part will receive the DataTable.
            ListReady(this, listReadyArgs);
        }
    }
}

Voir aussi

Référence

IListProvider interface

IListProvider - Membres

Microsoft.SharePoint.WebPartPages.Communication - Espace de noms