DataControlFieldCell, classe
Assembly : System.Web (dans system.web.dll)
La classe DataControlFieldCell est une classe TableCell fortement typée qui représente une cellule des contrôles liés aux données ASP.NET qui restituent leur contenu dans une présentation sous forme de tableau, telle que GridView et DetailsView.
L'objet DataControlField qui contient l'objet DataControlFieldCell contrôle le rendu de la cellule en appliquant des styles à la cellule. Vous pouvez accéder à l'objet DataControlField contenant à l'aide de la propriété ContainingField.
L'exemple de code suivant illustre comment un objet DataControlFieldCell peut être utilisé et manipulé par une classe qui dérive de DataControlField. La classe RadioButtonField ajoute un contrôle RadioButton à chaque objet DataControlFieldCell dans sa méthode InitializeCell et contrôle ensuite la valeur du contrôle RadioButton dans la méthode ExtractValuesFromCell. Cet exemple fait partie d'un exemple plus développé fourni pour la classe 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 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
- AspNetHostingPermission pour opérer dans un environnement hébergé. Valeur de demande : LinkDemand ; valeur d'autorisation : Minimal
- AspNetHostingPermission pour opérer dans un environnement hébergé. Valeur de demande : InheritanceDemand ; valeur d'autorisation : Minimal
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 Édition Media Center, Windows XP Professionnel Édition x64, Windows XP SP2, Windows XP Starter Edition
Le .NET Framework ne prend pas en charge toutes les versions de chaque plate-forme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise.