DataControlRowState 列挙体
この列挙体には、メンバ値のビットごとの組み合わせを可能にする FlagsAttribute 属性が含まれています。
名前空間: System.Web.UI.WebControlsアセンブリ: System.Web (system.web.dll 内)

<FlagsAttribute> _ Public Enumeration DataControlRowState

メンバ名 | 説明 | |
---|---|---|
Alternate | データ コントロール行が代替行であることを示します。 Alternate 状態は、Normal、Edit、または Insert など、他の状態と任意の時点で結合できます。これらの行は、データ コントロールの AlternateRowStyle プロパティによる影響を受ける場合があります (このプロパティが設定されている場合)。 | |
Edit | 行が編集状態であることを示します。通常、行の編集ボタンをクリックするとこの状態になります。通常、Edit 状態と Insert 状態はどちらか一方が適用されます。 | |
Insert | 行が新しい行であることを示します。通常、挿入ボタンをクリックして新しい行を追加するとこの状態になります。通常、Insert 状態と Edit 状態はどちらか一方が適用されます。 | |
Normal | データ コントロール行が通常の状態であることを示します。Normal 状態とその他の状態が同時に適用されることはありません。 | |
Selected | 行がユーザーに選択されたことを示します。 |

DataControlRowState 列挙値は、DetailsView または GridView など、データ コントロールの行の状態を識別します。行の状態は、1 つ以上の DataControlRowState 値の組み合わせで決まります。したがって、等価テストではなく、ビットごとの演算を使用して行の状態に DataControlRowState 値が含まれているかどうか確認します。DataControlRowState 列挙値は、DataRow 行だけでなく、あらゆるタイプの行に使用されます (通常、ヘッダー行およびフッター行の状態には Normal が設定されます)。
DataControlRowState 列挙値を使用すると、GridViewRowCollection または DetailsViewRowCollection コレクションを連続して調べられるので、GridViewRow または DetailsViewRow オブジェクトの状態を識別できます。行を使用するデータ コントロールを記述する場合、DataControlRowState 列挙値を使用すると、どの時点で行が別の色になったかを識別でき (Alternate 値)、コントロールで行の編集が有効か無効かを識別できます (Edit および Insert 値)。

次のコード例は、DataControlRowState 列挙値を使用して、GridView コントロール内の行の状態に基づき、ユーザー インターフェイス (UI: User Interface) を表示する方法を示しています。CheckBoxField コントロールから派生したカスタム フィールド コントロールである RadioButtonField クラスが、GridView コントロール内の各行にデータ バインド オプション ボタンを表示します。行がユーザーにデータを表示していて、さらに編集モードでない場合、RadioButton コントロールは無効になります。ユーザーが GridView 内の行を更新し、その行が編集モードの場合、使用可能な (クリックできる) RadioButton コントロールが表示されます。この例ではビットごとの AND 演算子を使用しています。これは、行の状態が 1 つ以上の DataControlRowState 値の組み合わせで決まるからです。このコード例は、DataControlField クラスのトピックで取り上げているコード例の一部分です。
' 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
// 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 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 (get_DataField().get_Length() != 0) { radio.add_DataBinding(new EventHandler(this.OnDataBindField)); } radio.set_Text(this.get_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.set_Enabled(false); // If the row is in edit mode, enable the button. if (((int)(rowState & DataControlRowState.Edit) != 0) || ((int)( rowState & DataControlRowState.Insert) != 0)) { radio.set_Enabled(true); } cell.get_Controls().Add(radio); } //InitializeDataCell

Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- DataControlRowState 列挙体のページへのリンク