DataControlField.InitializeCell 메서드

정의

셀의 컨트롤 컬렉션에 텍스트 또는 컨트롤을 추가합니다.

public:
 virtual void InitializeCell(System::Web::UI::WebControls::DataControlFieldCell ^ cell, System::Web::UI::WebControls::DataControlCellType cellType, System::Web::UI::WebControls::DataControlRowState rowState, int rowIndex);
public virtual void InitializeCell (System.Web.UI.WebControls.DataControlFieldCell cell, System.Web.UI.WebControls.DataControlCellType cellType, System.Web.UI.WebControls.DataControlRowState rowState, int rowIndex);
abstract member InitializeCell : System.Web.UI.WebControls.DataControlFieldCell * System.Web.UI.WebControls.DataControlCellType * System.Web.UI.WebControls.DataControlRowState * int -> unit
override this.InitializeCell : System.Web.UI.WebControls.DataControlFieldCell * System.Web.UI.WebControls.DataControlCellType * System.Web.UI.WebControls.DataControlRowState * int -> unit
Public Overridable Sub InitializeCell (cell As DataControlFieldCell, cellType As DataControlCellType, rowState As DataControlRowState, rowIndex As Integer)

매개 변수

cell
DataControlFieldCell

DataControlFieldCell의 텍스트나 컨트롤이 들어 있는 DataControlField입니다.

cellType
DataControlCellType

DataControlCellType 값 중 하나입니다.

rowState
DataControlRowState

DataControlRowState이 포함된 행의 상태를 지정하는 DataControlFieldCell 값 중 하나입니다.

rowIndex
Int32

DataControlFieldCell이 포함된 행의 인덱스입니다.

예제

다음 코드 예제를 구현 하는 방법에 설명 합니다 InitializeCell 에서 파생 되는 컨트롤에 대 한 메서드는 DataControlField 클래스입니다. 합니다 RadioButtonField 클래스의 모든 행에 대해 데이터 바인딩된 라디오 단추를 렌더링 한 GridView 컨트롤입니다. 행 데이터가 사용자에 게 표시 되 고 편집 모드에 있지는 RadioButton 컨트롤을 사용할 수 있습니다. 예를 들어에서 행을 업데이트 하려면 사용자가 편집 모드에 행이 되는 경우는 GridView 컨트롤은 RadioButton 클릭할 수 있도록 설정 하는 대로 컨트롤 렌더링 합니다. 이 예제에서는 행 상태 하나 이상의 조합일 수 있으므로 비트 AND 연산자를 사용 하 여 DataControlRowState 값입니다.

// This method adds a RadioButton control and any other 
// content to the cell's Controls collection.
protected override void InitializeDataCell
    (DataControlFieldCell cell, DataControlRowState rowState) {

  RadioButton radio = new RadioButton();

  // If the RadioButton is bound to a DataField, add
  // the OnDataBindingField method event handler to the
  // DataBinding event.
  if (DataField.Length != 0) {
    radio.DataBinding += new EventHandler(this.OnDataBindField);
  }

  radio.Text = this.Text;

  // Because the RadioButtonField is a BoundField, it only
  // displays data. Therefore, unless the row is in edit mode,
  // the RadioButton is displayed as disabled.
  radio.Enabled = false;
  // If the row is in edit mode, enable the button.
  if ((rowState & DataControlRowState.Edit) != 0 ||
      (rowState & DataControlRowState.Insert) != 0) {
    radio.Enabled = true;
  }

  cell.Controls.Add(radio);
}
' This method adds a RadioButton control and any other 
' content to the cell's Controls collection.
Protected Overrides Sub InitializeDataCell( _
    ByVal cell As DataControlFieldCell, _
    ByVal rowState As DataControlRowState)

    Dim radio As New RadioButton()

    ' If the RadioButton is bound to a DataField, add
    ' the OnDataBindingField method event handler to the
    ' DataBinding event.
    If DataField.Length <> 0 Then
        AddHandler radio.DataBinding, AddressOf Me.OnDataBindField
    End If

    radio.Text = Me.Text

    ' Because the RadioButtonField is a BoundField, it only 
    ' displays data. Therefore, unless the row is in edit mode, 
    ' the RadioButton is displayed as disabled.
    radio.Enabled = False
    ' If the row is in edit mode, enable the button.
    If (rowState And DataControlRowState.Edit) <> 0 _
        OrElse (rowState And DataControlRowState.Insert) <> 0 Then
        radio.Enabled = True
    End If

    cell.Controls.Add(radio)
End Sub

설명

파생 된 형식 DataControlField 구현 합니다 InitializeCell 텍스트 및 컨트롤을 추가 하는 방법을 DataControlFieldCell 사용자 인터페이스 (UI)를 표시할 테이블을 사용 하는 데이터 컨트롤에 속해 있는 개체입니다. 이러한 데이터 컨트롤 구조를 만들고 전체 테이블 행 단위로 때 해당 CreateChildControls 메서드를 호출 합니다. 합니다 InitializeCell 메서드를 호출 합니다 InitializeRow 메서드의 데이터와 같은 컨트롤 DetailsViewGridView합니다.

사용 하는 컨트롤을 데이터 바인딩된 사용자 지정을 작성 하는 경우이 메서드는 호출 하 여 DataControlFieldCell 개체의 데이터 또는 컨트롤을 사용 하 여 테이블 구조 셀을 초기화 합니다. 파생 된 클래스를 작성 하는 경우이 메서드를 구현 DataControlField합니다.

적용 대상

추가 정보