DataControlField::InitializeCell Method (DataControlFieldCell^, DataControlCellType, DataControlRowState, Int32)
Adds text or controls to a cell's controls collection.
Assembly: System.Web (in System.Web.dll)
public: virtual void InitializeCell( DataControlFieldCell^ cell, DataControlCellType cellType, DataControlRowState rowState, int rowIndex )
Parameters
- cell
-
Type:
System.Web.UI.WebControls::DataControlFieldCell^
A DataControlFieldCell that contains the text or controls of the DataControlField.
- cellType
-
Type:
System.Web.UI.WebControls::DataControlCellType
One of the DataControlCellType values.
- rowState
-
Type:
System.Web.UI.WebControls::DataControlRowState
One of the DataControlRowState values, specifying the state of the row that contains the DataControlFieldCell.
- rowIndex
-
Type:
System::Int32
The index of the row that the DataControlFieldCell is contained in.
Types derived from DataControlField implement the InitializeCell method to add text and controls to a DataControlFieldCell object that belongs to a data control that uses tables to display a user interface (UI). These data controls create the complete table structure row by row when their respective CreateChildControls methods are called. The InitializeCell method is called by the InitializeRow method of data controls such as DetailsView and GridView.
Call this method when you are writing a custom data-bound control that uses DataControlFieldCell objects to initialize the cells of the table structure with data or controls. Implement this method when you are writing a class derived from DataControlField.
The following code example demonstrates how to implement the InitializeCell method for a control that derives from the DataControlField class. The RadioButtonField class renders a data-bound radio button for every row in a GridView control. When the row is displaying data to a user and is not in edit mode, the RadioButton control is disabled. When the row is in edit mode, for example when the user chooses to update a row in the GridView control, the RadioButton control is rendered as enabled so that it can be clicked. This example uses bitwise AND operators, because the row state might be a combination of one or more DataControlRowState values.
Available since 2.0