This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.
Assembly: System.Web (in System.Web.dll)
|Indicates that the data control row is an alternate row. |
The state can be combined with other states, such as , , or , at any time. These rows might be affected by the AlternateRowStyle property of the data control, if set.
|Indicates that the row is in an edit state, often the result of clicking an edit button for the row. Typically, the and states are mutually exclusive.|
|Indicates that the row is a new row, often the result of clicking an insert button to add a new row. Typically, the and states are mutually exclusive.|
|Indicates that the data control row is in a normal state. The state is mutually exclusive with other states except the state.|
|Indicates that the row has been selected by the user.|
The enumeration identifies the state of a row in a data control such as DetailsView or GridView. A row's state can be one or a combination of the values, so use bitwise operations to determine whether the state of the row includes a value, rather than an equivalence test. The enumeration is used for any type of row, not just DataRow rows (typically, the state of header and footer rows is set to ).
You can use the enumeration to identify the state of a GridViewRow or DetailsViewRow object when enumerating through a GridViewRowCollection or DetailsViewRowCollection collection, respectively. If you are writing a data control that uses rows, you can use the enumeration to identify when to render different colors for a row (the value), or controls that are enabled or disabled for editing a row (the and values).
The following code example demonstrates how to use the enumeration to render a user interface (UI) based on the state of a row in a GridView control. The RadioButtonField class, which is a custom field control that derives from the CheckBoxField control, 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 user updates a row in GridView and the row is in edit mode, the RadioButton control is rendered as enabled so that it can be clicked. The example uses bitwise AND operators, because the row state might be a combination of one or more values. This code example is part of a larger example provided for the DataControlField class.
' 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
Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.