DataControlField.ExtractValuesFromCell 메서드

정의

현재 표 셀에서 데이터 컨트롤 필드의 값을 추출하여 지정된 IDictionary 컬렉션에 추가합니다.

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)

매개 변수

dictionary
IOrderedDictionary

IOrderedDictionary입니다.

cell
DataControlFieldCell

DataControlFieldCell의 텍스트나 컨트롤이 들어 있는 DataControlField입니다.

rowState
DataControlRowState

DataControlRowState 값 중 하나입니다.

includeReadOnly
Boolean

읽기 전용 필드의 값이 dictionary 컬렉션에 포함됨을 나타내려면 true이고, 그렇지 않으면 false입니다.

예제

다음 코드 예제를 구현 하는 방법에 설명 합니다 ExtractValuesFromCell 에서 파생 되는 컨트롤에 대 한 메서드는 DataControlField 클래스입니다. 합니다 RadioButtonField 클래스의 모든 행에 대해 데이터 바인딩된 라디오 단추를 렌더링 한 GridView 컨트롤입니다. 경우는 ExtractValuesFromCell 메서드가 호출 되 면 메서드를 확인 하려고 합니다. 여부를의 현재 값을는 RadioButton 셀에 포함 된 개체 또는 선택 취소 하면 선택한 값을 추가 합니다 IDictionary 컬렉션. 이 코드 예제는에 대해 제공 된 큰 예제의 일부는 DataControlField 클래스입니다.

// 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

설명

합니다 ExtractValuesFromCell 메서드는 파생 형식에서 구현 됩니다 DataControlField 해당 하는 경우 현재 필드 값을 사용 하 여 연결 합니다. 필드/값 쌍에 저장 되는 dictionary 메서드에 전달 되는 컬렉션입니다. 합니다 ExtractValuesFromCell 메서드를 호출 합니다 ExtractRowValues 메서드의 데이터와 같은 컨트롤 DetailsViewGridView합니다.

사용 하는 컨트롤을 데이터 바인딩된 사용자 지정을 작성 하는 경우이 메서드는 호출 하 여 DataControlFieldCell 셀과 연결 된 값의 집합을 조합 하는 개체입니다. 파생 된 클래스를 작성 하는 경우이 메서드를 구현 DataControlField 사용자 데이터 또는 데이터 바인딩된 데이터를 표시 하는 합니다. 모든 파생된 형식에서 구현 된 ExtractValuesFromCell 메서드를 일부 필드는 사용자 데이터를 표시 합니다. 예를 들어를 ButtonField 컨트롤의 단추를 표시 및 사용자 데이터가 없습니다.

적용 대상

추가 정보