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 のテキストまたはコントロールを格納する DataControlField。
- rowState
- DataControlRowState
DataControlRowState 値のいずれか 1 つ。
- 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、 や GridViewなどのDetailsViewデータ コントロールの メソッドによってExtractRowValues
呼び出されます。
オブジェクトを使用 DataControlFieldCell して一連のセルとそれに関連付けられた値をアセンブルするカスタム データ バインド コントロールを作成する場合は、このメソッドを呼び出します。 ユーザー データまたはデータ バインド データを表示する から DataControlField 派生したクラスを記述するときに、このメソッドを実装します。 すべてのフィールドにユーザー データが ExtractValuesFromCell 表示されるわけではないため、すべての派生型が メソッドを実装しているわけではありません。 たとえば、コントロールには ButtonField ボタンが表示され、ユーザー データがありません。
適用対象
こちらもご覧ください
.NET
フィードバック
https://aka.ms/ContentUserFeedback」を参照してください。
以下は間もなく提供いたします。2024 年を通じて、コンテンツのフィードバック メカニズムとして GitHub の issue を段階的に廃止し、新しいフィードバック システムに置き換えます。 詳細については、「フィードバックの送信と表示