System.Web.UI.WebControls Namespace DataControlField Class
.NET Framework version 2.0
Sets or retrieves the style properties of server controls contained in a DataControlField.
Script |
DataControlField.ControlStyle.Property [ = enumValue ] |
A Style that defines the style properties of server controls contained in a DataControlField.
Use the ControlStyle property to provide a custom style for server controls contained in types that derive from the DataControlField class. Common style attributes that can be set include forecolor, backcolor, font, and content alignment within the field.
This property does not affect all derived types. For example, the BoundField control typically displays text data and contains only TextBox controls, and is only affected by the ControlStyle property when in edit mode.
Field types such as ButtonField and CheckBoxField can be affected by the ControlStyle property, depending on the specific configuration of the controls contained in the field. For example, the ButtonField control can be rendered as a Button, LinkButton, or ImageButton control. While a LinkButton is affected by font attributes, a Button control is not.
The ControlStyle subproperties can be set declaratively using either of the following methods:
The subproperties can also be set programmatically in the form ControlStyle.Property.
For a list of style properties that can be set, see the Style class.
The following examples demonstrate using the ControlStyle property in different scenarios.
DataControlField Members FooterStyle HeaderStyle ItemStyle