DataControlFieldCell クラス
アセンブリ: System.Web (system.web.dll 内)
構文
解説DataControlFieldCell クラスは、GridView や DetailsView のように内容を表形式のレイアウトで表示する ASP.NET データ バインド コントロール内のセルを表す、厳密に型指定された TableCell クラスです。
DataControlFieldCell オブジェクトを格納する DataControlField オブジェクトは、セルにスタイルを適用して、セルの表示方法を制御します。DataControlField オブジェクトにアクセスするには、ContainingField プロパティを使用します。
使用例DataControlField から派生するクラスで、DataControlFieldCell オブジェクトを使用および操作するコード例を次に示します。RadioButtonField クラスは、RadioButton コントロールを InitializeCell メソッド内の各 DataControlFieldCell オブジェクトに追加し、後で ExtractValuesFromCell メソッド内の RadioButton コントロールの値を確認します。このコード例は、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 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
// 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 on GridView //and DetailsView. Retrieve // the current value of the cell from the Checked state of the Radio button. public void ExtractValuesFromCell(IOrderedDictionary dictionary, DataControlFieldCell cell, DataControlRowState rowState, boolean includeReadOnly) throws InvalidOperationException { // Does the cell contain a RadioButton in its Controls collection? if (cell.get_Controls().get_Count() > 0) { RadioButton radio = (RadioButton)cell.get_Controls().get_Item(0); 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 = (System.Boolean)radio.get_Checked(); } // Add the value of the Checked attribute of the // RadioButton to the dictionary. if (dictionary.Contains(get_DataField())) { dictionary.set_Item(get_DataField(), checkedValue); } else { dictionary.Add(get_DataField(), checkedValue); } } } //ExtractValuesFromCell
.NET Framework のセキュリティ
継承階層System.Web.UI.Control
System.Web.UI.WebControls.WebControl
System.Web.UI.WebControls.TableCell
System.Web.UI.WebControls.DataControlFieldCell
System.Web.UI.WebControls.DataControlFieldHeaderCell
スレッド セーフ
プラットフォームWindows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
参照- DataControlFieldCell クラスのページへのリンク