DataControlFieldCell Class
Assembly: System.Web (in system.web.dll)
The DataControlFieldCell class is a strongly typed TableCell class that represents a cell in ASP.NET data-bound controls that render their contents in a tabular layout, such as GridView and DetailsView.
The DataControlField object that contains the DataControlFieldCell object controls how the cell is rendered by applying styles to the cell. You can access the containing DataControlField object using the ContainingField property.
The following code example demonstrates how a DataControlFieldCell object can be used and manipulated by a class that derives from DataControlField. The RadioButtonField class adds a RadioButton control to each DataControlFieldCell object in its InitializeCell method, and later checks the value of the RadioButton control in the ExtractValuesFromCell method. This example is part of a larger example provided for the DataControlField class.
// 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 for operating in a hosted environment. Demand value: LinkDemand; Permission value: Minimal.
- AspNetHostingPermission for operating in a hosted environment. Demand value: InheritanceDemand; Permission value: 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