Click to Rate and Give Feedback
This page is specific to
Microsoft Visual Studio 2008/.Net Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
DataControlFieldCell Class

Represents a cell in the rendered table of a tabular ASP.NET data-bound control, such as DetailsView or GridView.

Namespace:  System.Web.UI.WebControls
Assembly:  System.Web (in System.Web.dll)
Visual Basic (Declaration)
<AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
<AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level := AspNetHostingPermissionLevel.Minimal)> _
Public Class DataControlFieldCell _
    Inherits TableCell
Visual Basic (Usage)
Dim instance As DataControlFieldCell
C#
[AspNetHostingPermissionAttribute(SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
public class DataControlFieldCell : TableCell
Visual C++
[AspNetHostingPermissionAttribute(SecurityAction::LinkDemand, Level = AspNetHostingPermissionLevel::Minimal)]
[AspNetHostingPermissionAttribute(SecurityAction::InheritanceDemand, Level = AspNetHostingPermissionLevel::Minimal)]
public ref class DataControlFieldCell : public TableCell
JScript
public class DataControlFieldCell extends TableCell
ASP.NET
<asp:DataControlFieldCell />

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.

Visual Basic
' 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

C#
// 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);
  }
}

J#
// 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

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker