共用方式為


RowReadyEventArgs.SelectionStatus property

NOTE: This API is now obsolete.

取得或設定所選取之列的類型。

Namespace:  Microsoft.SharePoint.WebPartPages.Communication
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'宣告
<ObsoleteAttribute("Use System.Web.UI.WebControls.WebParts.IWebPartRow instead")> _
Public Property SelectionStatus As String
    Get
    Set
'用途
Dim instance As RowReadyEventArgs
Dim value As String

value = instance.SelectionStatus

instance.SelectionStatus = value
[ObsoleteAttribute("Use System.Web.UI.WebControls.WebParts.IWebPartRow instead")]
public string SelectionStatus { get; set; }

Property value

Type: System.String
目前選取的列類型。SelectionStatus可以有下列三個區分大小寫值的其中一個。

描述

新增

表示新的或星狀列已選取資料工作表檢視控制項中。

會指出已選取 [無] 列。

標準

會指出已選取 [標準] 列。

Examples

下列程式碼範例會顯示覆寫的WebPart.PartCommunicationMain方法會建立RowReadyEventArgs物件、 設定列值和選取狀態,並接著會引發RowReady事件。此程式碼範例會是範例的較大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
      'If there is a listener, fire the RowReady event.
      If Not (RowReady Is Nothing) 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 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 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 selection status.
                selectionStatus = "None";
            }

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

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

請參閱

參照

RowReadyEventArgs class

RowReadyEventArgs members

Microsoft.SharePoint.WebPartPages.Communication namespace