DataControlField.ExtractValuesFromCell(IOrderedDictionary, DataControlFieldCell, DataControlRowState, Boolean) DataControlField.ExtractValuesFromCell(IOrderedDictionary, DataControlFieldCell, DataControlRowState, Boolean) DataControlField.ExtractValuesFromCell(IOrderedDictionary, DataControlFieldCell, DataControlRowState, Boolean) DataControlField.ExtractValuesFromCell(IOrderedDictionary, DataControlFieldCell, DataControlRowState, Boolean) Method

Definizione

Estrae il valore del campo di controllo dati dalla cella corrente della tabella e aggiunge il valore all'insieme IDictionary specificato.Extracts the value of the data control field from the current table cell and adds the value to the specified IDictionary collection.

public:
 virtual void ExtractValuesFromCell(System::Collections::Specialized::IOrderedDictionary ^ dictionary, System::Web::UI::WebControls::DataControlFieldCell ^ cell, System::Web::UI::WebControls::DataControlRowState rowState, bool includeReadOnly);
public virtual void ExtractValuesFromCell (System.Collections.Specialized.IOrderedDictionary dictionary, System.Web.UI.WebControls.DataControlFieldCell cell, System.Web.UI.WebControls.DataControlRowState rowState, bool includeReadOnly);
abstract member ExtractValuesFromCell : System.Collections.Specialized.IOrderedDictionary * System.Web.UI.WebControls.DataControlFieldCell * System.Web.UI.WebControls.DataControlRowState * bool -> unit
override this.ExtractValuesFromCell : System.Collections.Specialized.IOrderedDictionary * System.Web.UI.WebControls.DataControlFieldCell * System.Web.UI.WebControls.DataControlRowState * bool -> unit
Public Overridable Sub ExtractValuesFromCell (dictionary As IOrderedDictionary, cell As DataControlFieldCell, rowState As DataControlRowState, includeReadOnly As Boolean)

Parametri

cell
DataControlFieldCell DataControlFieldCell DataControlFieldCell DataControlFieldCell

Oggetto DataControlFieldCell contenente il testo o i controlli dell'oggettoDataControlField.A DataControlFieldCell that contains the text or controls of the DataControlField.

includeReadOnly
Boolean Boolean Boolean Boolean

true per indicare che i valori dei campi in sola lettura sono inclusi nell'insieme dictionary; in caso contrario, false.true to indicate that the values of read-only fields are included in the dictionary collection; otherwise, false.

Esempi

Nell'esempio di codice seguente viene illustrato come implementare ExtractValuesFromCell il metodo per un controllo che deriva DataControlField dalla classe.The following code example demonstrates how to implement the ExtractValuesFromCell method for a control that derives from the DataControlField class. La RadioButtonField classe esegue il rendering di un pulsante di opzione associato a dati per ogni GridView riga in un controllo.The RadioButtonField class renders a data-bound radio button for every row in a GridView control. Quando viene ExtractValuesFromCell chiamato il metodo, il metodo tenta di determinare se il valore corrente RadioButton dell'oggetto contenuto nella cella è selezionato o deselezionato e IDictionary aggiunge il valore alla raccolta.When the ExtractValuesFromCell method is called, the method attempts to determine whether the current value of the RadioButton object contained in the cell is selected or cleared, and adds the value to the IDictionary collection. Questo esempio di codice fa parte di un esempio più ampio fornito DataControlField per la classe.This code example is part of a larger example provided for the DataControlField class.

// This method is called by the ExtractRowValues methods of 
// GridView and DetailsView. Retrieve the current value of the 
// cell from the Checked state of the Radio button.
public override void ExtractValuesFromCell(IOrderedDictionary dictionary,
                                           DataControlFieldCell cell,
                                           DataControlRowState rowState,
                                           bool includeReadOnly)
{

  // Determine whether the cell contains a RadioButton 
  // in its Controls collection.
  if (cell.Controls.Count > 0) {
    RadioButton radio = cell.Controls[0] as RadioButton;

    object checkedValue = null;
    if (null == radio) {
      // A RadioButton is expected, but a null is encountered.
      // Add error handling.
      throw new InvalidOperationException
          ("RadioButtonField could not extract control.");
    }
    else {
        checkedValue = radio.Checked;
    }


    // Add the value of the Checked attribute of the
    // RadioButton to the dictionary.
    if (dictionary.Contains(DataField))
      dictionary[DataField] = checkedValue;
    else
      dictionary.Add(DataField, checkedValue);
  }
}
' This method is called by the ExtractRowValues methods of
' GridView and DetailsView. Retrieve the current value of the 
' cell from the Checked state of the Radio button.
Public Overrides Sub ExtractValuesFromCell( _
    ByVal dictionary As IOrderedDictionary, _
    ByVal cell As DataControlFieldCell, _
    ByVal rowState As DataControlRowState, _
    ByVal includeReadOnly As Boolean)
    ' Determine whether the cell contain a RadioButton 
    ' in its Controls collection.
    If cell.Controls.Count > 0 Then
        Dim radio As RadioButton = CType(cell.Controls(0), RadioButton)

        Dim checkedValue As Object = Nothing
        If radio Is Nothing Then
            ' A RadioButton is expected, but a null is encountered.
            ' Add error handling.
            Throw New InvalidOperationException( _
                "RadioButtonField could not extract control.")
        Else
            checkedValue = radio.Checked
        End If


        ' Add the value of the Checked attribute of the
        ' RadioButton to the dictionary.
        If dictionary.Contains(DataField) Then
            dictionary(DataField) = checkedValue
        Else
            dictionary.Add(DataField, checkedValue)
        End If
    End If
End Sub

Commenti

Il ExtractValuesFromCell metodo viene implementato dai tipi derivati da DataControlField per associare il campo corrente a un valore, se applicabile.The ExtractValuesFromCell method is implemented by types derived from DataControlField to associate the current field with a value, if applicable. La coppia campo/valore viene archiviata nella dictionary raccolta passata al metodo.The field/value pair is stored in the dictionary collection that is passed to the method. Il ExtractValuesFromCell metodo viene chiamato ExtractRowValues dal metodo DetailsView dei controlli dati, ad esempio e GridView.The ExtractValuesFromCell method is called by the ExtractRowValues method of data controls such as DetailsView and GridView.

Chiamare questo metodo quando si scrive un controllo con associazione a dati personalizzato che usa DataControlFieldCell oggetti per assemblare un set di celle e i relativi valori associati.Call this method when you are writing a custom data-bound control that uses DataControlFieldCell objects to assemble a set of cells and their associated values. Implementare questo metodo quando si scrive una classe derivata da DataControlField che Visualizza dati utente o dati associati a dati.Implement this method when you are writing a class derived from DataControlField that displays user data or data-bound data. Non tutti i tipi derivati implementano il ExtractValuesFromCell metodo, perché non tutti i campi visualizzano i dati utente.Not all derived types implement the ExtractValuesFromCell method, because not all fields display user data. Ad esempio, il ButtonField controllo Visualizza un pulsante e non contiene dati utente.For example, the ButtonField control displays a button and has no user data.

Si applica a

Vedi anche