DataControlField.InitializeCell 메서드
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
셀의 컨트롤 컬렉션에 텍스트 또는 컨트롤을 추가합니다.
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포함하는 A DataControlField 입니다.
- cellType
- DataControlCellType
값 중 DataControlCellType 하나입니다.
- rowState
- DataControlRowState
를 DataControlRowState 포함하는 행의 상태를 지정하는 값 중 하나입니다 DataControlFieldCell.
- rowIndex
- Int32
포함된 행 DataControlFieldCell 의 인덱스입니다.
예제
다음 코드 예제에서는 클래스에서 InitializeCell 파생 되는 컨트롤에 대 한 메서드를 구현 DataControlField 하는 방법을 보여 줍니다. 클래스는 RadioButtonField 컨트롤의 모든 행에 대해 데이터 바인딩된 라디오 단추를 렌더링합니다 GridView . 행이 사용자에게 데이터를 표시하고 편집 모드가 아닌 경우 컨트롤이 RadioButton 비활성화됩니다. 행이 편집 모드인 경우(예: 사용자가 컨트롤에서 GridView 행을 업데이트하도록 선택하면 컨트롤 RadioButton 을 클릭할 수 있도록 컨트롤이 활성화된 상태로 렌더링됩니다. 이 예제에서는 행 상태가 하나 이상의 DataControlRowState 값 조합일 수 있으므로 비트 AND 연산자를 사용합니다.
// 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
설명
테이블을 사용하여 UI(사용자 인터페이스)를 표시하는 데이터 컨트롤에 속하는 개체에 텍스트 및 컨트롤 DataControlField 을 추가하는 메서드 구현 InitializeCell 에서 DataControlFieldCell 파생된 형식입니다. 이러한 데이터 컨트롤은 각 CreateChildControls 메서드가 호출되면 행별로 전체 테이블 구조 행을 만듭니다. 메서드는 InitializeCell 같은 InitializeRow 데이터 컨트롤의 메서드에 의해 DetailsView 호출 됩니다.GridView
개체를 사용하여 데이터 또는 컨트롤을 사용하여 DataControlFieldCell 테이블 구조의 셀을 초기화하는 사용자 지정 데이터 바인딩된 컨트롤을 작성할 때 이 메서드를 호출합니다. 에서 파생된 DataControlField클래스를 작성할 때 이 메서드를 구현합니다.