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
DataControlFieldのテキストまたはコントロールを含むDataControlFieldCell。
- rowState
- DataControlRowState
DataControlRowState値の 1 つ。
- includeReadOnly
- Boolean
true 読み取り専用フィールドの値が dictionary コレクションに含まれていることを示す場合は。それ以外の場合は false。
例
次のコード例では、DataControlField クラスから派生するコントロールのExtractValuesFromCell メソッドを実装する方法を示します。
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 メソッドは、DetailsViewやGridViewなどのデータ コントロールのExtractRowValues メソッドによって呼び出されます。
DataControlFieldCell オブジェクトを使用して一連のセルとそれに関連付けられた値をアセンブルするカスタム データ バインド コントロールを作成するときに、このメソッドを呼び出します。 ユーザー データまたはデータ バインド データを表示する DataControlField から派生したクラスを記述するときに、このメソッドを実装します。 すべてのフィールドにユーザー データが表示されるわけではないため、すべての派生型が ExtractValuesFromCell メソッドを実装しているわけではありません。 たとえば、 ButtonField コントロールにはボタンが表示され、ユーザー データはありません。