Partager via


IRowProvider.RowReady - Événement

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

Se produit lorsque la ligne sélectionnée dans un composant WebPart fournisseur, par exemple lorsqu'une ligne est mis à jour ou sélectionnée.

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

Syntaxe

'Déclaration
<ObsoleteAttribute("Use System.Web.UI.WebControls.WebParts.IWebPartRow instead")> _
Event RowReady As RowReadyEventHandler
'Utilisation
Dim instance As IRowProvider
Dim handler As RowReadyEventHandler

AddHandler instance.RowReady, handler
[ObsoleteAttribute("Use System.Web.UI.WebControls.WebParts.IWebPartRow instead")]
event RowReadyEventHandler RowReady

Remarques

Le Gestionnaire d'événements reçoit un argument de type Microsoft.SharePoint.WebPartPages.Communication.RowReadyEventArgs contenant des données liées à cet événement. Le suivant RowReadyEventArgs de propriétés Rows et SelectionStatus fournissent des informations spécifiques à cet événement

Exemples

L'exemple de code suivant montre une méthode substituée PartCommunicationMain qui crée un objet deRowReadyEventArgs, définit les valeurs de ligne et l'état de sélection, puis déclenche l'événement RowReady . Cet exemple de code fait partie d'un exemple plus développé fourni pour l'interface IRowProvider .

      ' 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 RowReady event. Some parts
      ' may not behave properly if they are left waiting for this 
      ' information.
       Public Overrides Sub PartCommunicationMain()
            ' Check if connected.
            If _connected Then
                'Create the RowReadyEventArgs object for the RowReady event.
                Dim rowReadyEventArgs As New RowReadyEventArgs()

                ' Declare data variables.
                Dim selectionStatus As String = ""
                Dim dr(0) As DataRow

                ' If a row is selected, send the row.
                If _dataGrid.SelectedIndex > -1 Then
                    ' Generate an array containing the selected DataRow(s).
                    dr(0) = CType(_dataGrid.DataSource, DataTable).Rows(_dataGrid.SelectedIndex)

                    ' Set the selection status.
                    selectionStatus = "Standard"

                Else
                    ' The user hasn't selected a row so send null.
                    dr(0) = Nothing

                    ' Set the selection status.
                    selectionStatus = "None"
                End If

                ' Set values.
                rowReadyEventArgs.Rows = dr
                rowReadyEventArgs.SelectionStatus = selectionStatus

                ' Fire the RowReady event.
                RaiseEvent RowReady(Me, rowReadyEventArgs)
            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 RowReady event. Some 
        // parts may not behave properly if they are left waiting for 
        // this information.
        public override void PartCommunicationMain()
        {
            // Check if connected.
            if(_connected)
            {
                //If there is a listener, fire the RowReady event.
                if (RowReady != null)
                {
                    // Create the RowReadyEventArgs object for the 
                    // RowReady event.
                    RowReadyEventArgs rowReadyEventArgs = new RowReadyEventArgs();

                    // Declare data variables.
                    string selectionStatus = "";
                    DataRow[] dr = new DataRow[1];

                    // If a row is selected, send the row.
                    if ( _dataGrid.SelectedIndex > -1)
                    {
                        // Generate an array containing the selected 
                        // DataRow(s).
                        dr[0] = ((DataTable)_dataGrid.DataSource).Rows[_dataGrid.SelectedIndex];
                    
                        // Set the selection status.
                        selectionStatus = "Standard";

                    }
                    else
                    {
                        // The user hasn't selected a row so send null.
                        dr[0] = null;

                        // Set the selection status.
                        selectionStatus = "None";
                    }

                    // Set values.
                    rowReadyEventArgs.Rows = dr;
                    rowReadyEventArgs.SelectionStatus = selectionStatus;

                    // Fire the RowReady event.
                    RowReady(this, rowReadyEventArgs);
                }
            }
        }

Voir aussi

Référence

IRowProvider interface

IRowProvider - Membres

Microsoft.SharePoint.WebPartPages.Communication - Espace de noms