DataControlField.ExtractValuesFromCell 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
현재 테이블 셀에서 데이터 제어 필드의 값을 추출하고 지정된 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
- cell
- DataControlFieldCell
의 텍스트 또는 컨트롤을 DataControlFieldCell포함하는 A DataControlField 입니다.
- rowState
- DataControlRowState
값 중 DataControlRowState 하나입니다.
- includeReadOnly
- Boolean
true 읽기 전용 필드의 값이 컬렉션에 포함됨을 dictionary 나타내려면 이고, 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 데이터 컨트롤의 메서드에 의해 DetailsView 호출 됩니다.GridView
개체를 사용하여 DataControlFieldCell 셀 집합과 관련 값을 어셈블하는 사용자 지정 데이터 바인딩된 컨트롤을 작성할 때 이 메서드를 호출합니다. 사용자 데이터 또는 데이터 바인딩된 데이터를 표시하는 파생 DataControlField 클래스를 작성할 때 이 메서드를 구현합니다. 모든 파생 형식이 메서드를 ExtractValuesFromCell 구현하는 것은 아닙니다. 모든 필드에 사용자 데이터가 표시되지 않기 때문입니다. 예를 들어 컨트롤에 ButtonField 단추가 표시되고 사용자 데이터가 없습니다.